#include <iostream>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;

static const double INF = 1e9;
static const double EPS = 1e-9;

template<class T>
T sqr(T obj) {
	return obj * obj;
}

struct building {
	int b;
	int x;
	int y;

	building(int b_, int x_, int y_) {
		b = b_;
		x = x_;
		y = y_;
	}
};

struct edge {
	int to;
	double cost;
	edge() {}
	edge(int t, double c) {
		to = t;
		cost = c;
	}
};

struct edge1 {
	int from;
	int cur;
	double cost;

	edge1() {}
	edge1(int from_, int cur_, double cost_) {
		from = from_;
		cur = cur_;
		cost = cost_;
	}

	bool operator<(const edge1 & e) const {
		return cost > e.cost;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		vector<building> v;
		vector<vector<edge> > dist(1024, vector<edge>());
		for(int i = 0; i < n; i++) {
			int b, x, y;
			cin >> b >> x >> y;
			v.push_back(building(b, x, y));
		}

		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v.size(); j++) {
				double d;
				d = sqrt(sqr(v[i].x - v[j].x) + sqr(v[i].y - v[j].y));
				if(d <= 50.0) {
					dist[v[i].b].push_back(edge(v[j].b, d));
				}
			}
		}

		int m;
		cin >> m;
		for(int t = 0; t < m; t++) {
			int s, g;
			cin >> s >> g;
			pair<double,int> cost[1024];
			bool updateflg[1024];
			for(int i = 0; i < 1024; i++) {
				cost[i].first = INF;
				cost[i].second = -1;
				updateflg[i] = true;
			}
			cost[s].first = 0;

			priority_queue<edge1> q;
			q.push(edge1(-1, s, 0));

		//	cout << "dijkstra start" << endl;
			while(!q.empty()) {
				edge1 current;
				current = q.top(); q.pop();
				if(updateflg[current.cur]) {
					cost[current.cur].first = current.cost;
					cost[current.cur].second = current.from;
					updateflg[current.cur] = false;

					for(int i = 0; i < dist[current.cur].size(); i++) {
						if(updateflg[dist[current.cur][i].to]) {
							q.push(edge1(current.cur, dist[current.cur][i].to, current.cost + dist[current.cur][i].cost));
						}
					}
				}
			}
		//	cout << "dijkstra end" << endl;
		//	cout << "cost:" << cost[g].first << " from:" << cost[g].second << endl;

			stack<int> path;
			int indx = g;
			while(cost[indx].second != -1) {
				path.push(indx);
				indx = cost[indx].second;
			}

			if(path.size() == 0)
				cout << "NA" << endl;
			else {
				cout << s;
				while(!path.empty()) {
					cout << " " << path.top();
					path.pop();
				}
				cout << endl;
			}
		}
	}
}