#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;
typedef complex<double> Point;
const double EPS=1e-10;
const double INFTY=1e10;

void WarshallFloyd(vvd& dist,vvi& next)
{
	int n=dist.size();
	
	rep(i,n) rep(j,n)
		next[i][j]=j;
	
	rep(k,n) rep(i,n) rep(j,n){
		if(dist[i][j]>dist[i][k]+dist[k][j]){
			dist[i][j]=dist[i][k]+dist[k][j];
			next[i][j]=next[i][k];
		}
	}
}

int main()
{
	for(int n;cin>>n,n;){
		vi b(n);
		vector<Point> p(n);
		rep(i,n)
			cin>>b[i]>>real(p[i])>>imag(p[i]);

		vvd dist(n,vd(n,INFTY));
		rep(i,n) rep(j,n)
			if(abs(p[i]-p[j])<50+EPS)
				dist[i][j]=abs(p[i]-p[j]);
		vvi next(n,vi(n));
		WarshallFloyd(dist,next);
		
		int m; cin>>m;
		rep(i,m){
			int s,g; cin>>s>>g;
			int si=-1,gi=-1;
			rep(i,n){
				if(b[i]==s) si=i;
				if(b[i]==g) gi=i;
			}
			if(abs(dist[si][gi]-INFTY)<EPS)
				cout<<"NA"<<endl;
			else{
				for(int j=si;j!=gi;j=next[j][gi])
					cout<<b[j]<<" ";
				cout<<g<<endl;
			}
		}
	}

	return 0;
}