#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem0155 : Spider Jin **/
int cost[1000][1000];
int d[1000];
bool used[1000];
int V;

int prev[1000];

void dijkstra(int s)
{
	fill(d, d+V, INF);
	fill(used, used+V, false);
	fill(prev, prev+V, -1);
	d[s]=0;
	
	while (true) {
		int v=-1;
		
		for (int u=0; u<V; u++) {
			if (!used[u] && (v==-1 || d[u]<d[v]))
				v=u;
		}
		if (v==-1) break;
		used[v] = true;
		
		for (int u=0; u<V; u++) {
			if (d[u]>d[v]+cost[v][u]) {
				d[u] = d[v]+cost[v][u];
				prev[u] = v;
			}
		}
	}
}

int main()
{
	while (cin>>V, V) {
		vector<P> p;
		rep(i, V) {
			int a, b, c;
			cin>>a>>b>>c;
			p.push_back(P(a-1, b, c));
		}
		
		fill(cost[0], cost[0]+1000*1000, INF);
		rep(i, V) {
			rep(j, V) {
				if (i!=j) {
					int a = p[i].n, b=p[j].n;
					double d = sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y));
					if (d<=50)
						cost[a][b] = cost[b][a] = d;
				}
			}
		}
		
		int N; cin>>N;
		while (N--) {
			int s, t;
			cin>>s>>t;
			s--, t--;
			
			dijkstra(s);
			vector<int> path;
			for (; t!=-1; t=prev[t]) path.push_back(t);
			reverse(path.begin(), path.end());
		
			if (path.size()>1) {
				rep(i, path.size()) {
					if (i!=0) cout << " ";
					cout << path[i]+1;
				}
				cout << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
}