#include <iostream>
#include <cmath>
#define INF 1e+9
#define EPS 1e-9
using namespace std;

int main(){
	int n,b[100];
	double x[100],y[100];
	double cost[100][100];
	int next[100][100];
	while(cin >> n,n){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++) {
				cost[i][j] = INF;
				next[i][j] = j;
			}
			cost[i][i] = 0;
		}
		for(int i = 0;i < n;i++) cin >> b[i] >> x[i] >> y[i];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				double d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
				if(i != j && d <= 2500.0){
					cost[i][j] = d;
					cost[j][i] = d;
				}
			}
		}
		for(int k = 0;k < n;k++){
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					if(cost[i][j] > cost[i][k] + cost[k][j]){
						cost[i][j] = cost[i][k] + cost[k][j];
						next[i][j] = next[i][k];
					}
				}
			}
		}
		int m;
		cin >> m;
		for(int i = 0;i < m;i++){
			int s,g,S,G;
			cin >> s >> g;
			for(int j = 0;j < n;j++){
				if(b[j] == s) S = j;
				if(b[j] == g) G = j;
			}
			if(cost[S][G] == INF){
				cout << "NA" << endl;
				continue;
			}
			while(S != G){
				cout << b[S] << " ";
				S = next[S][G];
			}
			cout << b[G] << endl;
		}
	}
	
	return 0;
}