import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

int d2(int[] xy1, int[] xy2) {
    int[2] dxy = xy1[] - xy2[];
    return dxy[0]*dxy[0] + dxy[1]*dxy[1];
}

int[] search(Tuple!(int, double)[][] gl, int s, int g) {
    auto pre = new int[](gl.length);
    auto used = new bool[](gl.length);
    //cost, idx, preIdx
    auto rbt = new RedBlackTree!(Tuple!(double, int, int));
    rbt.insert(tuple(0., s, -1));
    while(!rbt.empty()) {
        auto t = rbt.front;
        rbt.removeFront();
        auto idx = t[1];
        auto preIdx = t[2];
        if(used[idx]) {
            continue;
        }
        used[idx] = true;
        pre[idx] = preIdx;
        foreach(u; gl[idx]) {
            if(used[u[0]]) {
                continue;
            }
            rbt.insert(tuple(t[0] + u[1], u[0], idx));
        }
    }
    if(!used[g]) {
        return null;
    }
    auto ans = [g];
    while(ans.front != s) {
        ans = pre[ans.front] ~ ans;
    }
    return ans;
}


void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            return;
        }
        auto xy = new int[][](n);
        foreach(i; iota(n)) {
            auto bxy = readInts();
            xy[bxy[0]-1] ~= bxy[1..$];
        }
        auto minL = new int[][](n, n);
        auto gl = new Tuple!(int, double)[][](n, 0);
        foreach(i; iota(n)) {
            foreach(j; iota(n)) {
                int d2_ = d2(xy[i], xy[j]);
                if(d2_ <= 50*50) {
                    gl[i] ~= tuple(j, sqrt(d2_.to!double));
                    gl[j] ~= tuple(i, sqrt(d2_.to!double));
                }
            }
        }
        auto m = readInt();
        foreach(i; iota(m)) {
            int s, g;
            readlnTo(s, g);
            --s;
            --g;
            auto ans = search(gl, s, g);
            if(ans) {
                writeln(ans.map!(a => (a+1).to!string).join(" "));
            } else {
                writeln("NA");
            }
        }
    }
}