#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);


using Weight = int;
class Edge {
public:
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, Weight w = INF) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
//???????????\: g[u].push_back(Edge(u, v, c));
//????????¨???????????????????????°??????????????\?????????????????????
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };
//???????§?????????????(???????????????) Single Source Shortest Path
//Dijkstra O( |E|log|V| )
//dist: ?§????????????????????????§??????????????¢
//?????????: ???????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, vector<Weight> &dist) {
	typedef tuple<Weight, int, int> State; //?§?????????????????°?????????? ??? ???
	priority_queue<State, vector<State>, greater<State> >PQ;
	int n = g.size();
	vector<int> color(n, WHITE);
	vector<int> prev(n, -1);
	dist.assign(n, INF); //distance
	dist[s] = 0; PQ.emplace(0, s, -1); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v; int u;
		tie(d, v, u) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		prev[v] = u;
		for (auto &e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.emplace(dist[e.d], e.d, v);
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}

//?§?????????????????????§??????????????????
//???????????????????????°?????????????§??????????????????§?????????????????¢????????????
//?????¨???????????´???????????????: vector<int>()
vector<int> getPath(int s, int g, vector<int> prev) {
	vector<int> path;
	path.emplace_back(g);
	for (int i = g; i != s; ) {
		if (i == -1)return vector<int>();
		path.emplace_back(i = prev[i]);
	}
	reverse(path.begin(), path.end());
	return path;
}

class B {
public:
	int b, x, y;
};

int d(B B1, B B2) {
	return (B1.x - B2.x)*(B1.x - B2.x) + (B1.y - B2.y)*(B1.y - B2.y);
}

signed main() {
	for (int n; cin >> n&&n;) {
		Graph g(n);
		vector<B> Bs(n);
		rep(i, 0, n) {
			cin >> Bs[i].b >> Bs[i].x >> Bs[i].y;
			Bs[i].b--;
		}
		rep(i, 0, n)rep(j, 0, n) {
			if (i == j)continue;
			int dd = d(Bs[i], Bs[j]);
			if (dd > 50 * 50)continue;
			g[Bs[i].b].emplace_back(Bs[i].b, Bs[j].b, dd);
		}
		int m; cin >> m;
		rep(i, 0, m) {
			int start, goal; cin >> start >> goal;
			start--, goal--;
			vector<Weight> dist;
			vector<int> prev = dijkstra(g, start, dist);
			vector<int> path = getPath(start, goal, prev);
			if (path.size() == 0) {
				cout << "NA" << endl;
				continue;
			}
			cout << path[0] + 1;
			rep(j, 1, path.size())cout << " " << path[j] + 1;
			cout << endl;
		}
	}
	return 0;
}