#include <iostream>
#include <vector>

using namespace std;

/*?§?????????????*/
struct node {
	vector<int> edges_to;
	vector<int> edges_cost;
	int n_edges, done, cost, from, exist;
};

struct building {
	int x, y, exist;
};

/*??¢??°??????????????????*/
int buidingInterval(int x1, int y1, int x2, int y2);
void getPath(struct node *nodes, int start);

int main() {
	int n, m, num, s, g, path[1001];
	struct node nodes[1001];
	struct building b[1001];

	while (cin >> n, n) {
		/*?????????*/
		for (int i = 0; i < 1001; i++) {
			nodes[i].edges_to.clear();
			nodes[i].edges_cost.clear();
			nodes[i].n_edges = 0;
			nodes[i].done = 0;
			nodes[i].cost = -1;
			nodes[i].from = -1;
			nodes[i].exist = 0;
			b[i].x = -1;
			b[i].y = -1;
			b[i].exist = 0;
		}

		/*??\???*/
		for (int i = 0; i < n; i++) {
			cin >> num;
			cin >> b[num].x >> b[num].y;
			b[num].exist = 1;
			nodes[num].exist = 1;
		}


		/*?????????????????????*/
		for (int i = 1; i < 1001; i++) {
			if (b[i].exist) {
				for (int j = 1; j < 1001; j++) {
					if (b[j].exist && i != j) {
						int x1 = b[i].x,
							y1 = b[i].y,
							x2 = b[j].x,
							y2 = b[j].y,
							bi = buidingInterval(x1, y1, x2, y2);

						if ((x1 - x2 < 50 || x2 - x1 < 50) && (y1 - y2 < 50 || y2 - y1 < 50)) {

							if (bi <= 2500) {
								nodes[i].edges_to.push_back(j);
								nodes[i].edges_cost.push_back(bi);
								nodes[i].n_edges++;
								//nodes[j].edges_to.push_back(j);
								//nodes[j].edges_cost.push_back(bi);
								//nodes[j].n_edges++;
							}

						}
					}
				}
			}
		}

		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> s >> g;

			/*???????????????????????????????????????????????±??¨??????????????°???????????????*/
			getPath(nodes, s);

			/*?????????????´?*/
			int cont = 0, from = nodes[g].from;
			while (from != -1) {
				path[cont] = from;
				from = nodes[from].from;
				cont++;
			}

			/*????????????*/
			if (path[cont-1] == s) {
				for (int j = cont - 1; j >= 0; j--) {
					cout << path[j] << ' ';
				}
				cout << g << endl;
			}
			else {
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}


/*??¢??°??????*/
int buidingInterval(int x1, int y1, int x2, int y2) {
	/*2?????????????????§?¨????????????????????????¢??????????????????*/
	return (((x1-x2)*(x1-x2)) + ((y1-y2)*(y1-y2)));
}

void getPath(struct node *nodes, int start) {
	/*?????????????????????*/
	int to, cost, from;
	struct node *done_node;

	nodes[start].cost = 0;

	while (1) {
		done_node = NULL;

		/*?¢???????????????????????¨??????????????????????????????????????????????????????????*/
		for (int i = 1; i < 1001; i++) {
			if (nodes[i].exist) {
				if (nodes[i].done || nodes[i].cost == -1) {
					continue;
				}
				else if (done_node == NULL || nodes[i].cost < done_node->cost) {
					done_node = &nodes[i];
					from = i;
				}
			}
		}
		/*?¢????????????????????????????????????????*/
		if (done_node == NULL)	break;

		/*?????????????¢?????????????*/
		done_node->done = 1;

		/*???????¢???????????????????????????\?¶????????????±?????´??°*/
		for (int i = 0; i < done_node->n_edges; i++) {
			to = done_node->edges_to[i];
			cost = done_node->cost + done_node->edges_cost[i];

			if (nodes[to].cost == -1 || (!(nodes[to].done) && cost < nodes[to].cost)) {
				nodes[to].cost = cost;
				nodes[to].from = from;
			}
		}
	}
}