#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<double,ll> mp;
double inf =1e9;
#define EPS 1e-10
struct point{
	double x,y;
	void make(){
		cin>>x>>y;
	}
	point(){};
	point(double x,double y):x(x),y(y){};
	point operator + (point &p) { return point(x+p.x,y+p.y)  ; }
	point operator - (point &p) { return point(x-p.x,y-p.y)  ; }
	double norm() { return x*x+y*y;}
	double abs() { return sqrt(norm()) ;}
};

typedef pair<int,point> mmp;

struct line{
	point s,e;
};

double cross(point a,point b){
	return a.x*b.y-a.y*b.x;
}
double dot(point a,point b){
	return a.x*b.x+a.y*b.y;
}

struct circle{
	point p;
	double r;
	void make(){
		p.make();
		cin>>r;
	}
};

double abs(point a){
	return a.abs();
}
double distance(line l,point p){
	point tmp = l.e-l.s;
	if(dot(tmp,p-l.s) < EPS) return abs(p-l.s);
	if(dot(l.s-l.e,p-l.e) < EPS ) return abs(p-l.e);
	return abs(cross(l.e-l.s,p-l.s ) / abs(l.e-l.s) );
}

typedef pair<mp,int> mpp;
vector<mp> daikus(vector<vector<double> > &g,int s){
	vector<mp> cost(g.size(),mp( inf,g.size() ) );
	vector<bool> used(g.size(),false);
	priority_queue<mpp,vector<mpp>,greater<mpp> > q;
	q.push( mpp(mp(0.0,s),g.size())  );
	cost[s] = mp( 0.0,g.size() );
	while(!q.empty()){
		mp now = q.top().first;
		int prev = q.top().second;
		double nowc = now.first;
		int nn = now.second;
		q.pop();
		if(used[nn])continue;
		used[nn] = true;
		cost[nn] = mp(nowc,prev);
		for(int i=0;i<g.size();i++){
			double nextc = g[nn][i];
			if(nextc>50.0){
				continue;
			}
			if(used[i]) continue;
			q.push(mpp(mp(nowc+nextc,i),nn) );
		}
	}
	return cost;
}

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		vector<mmp> a(n);
		map<int,int> hen;
		for(int i=0;i<n;i++){
			cin>>a[i].first;
			a[i].second.make();
			hen[a[i].first] = i;
		}
		vector<vector<double> > g(n,vector<double>(n,inf) );
		for(int i=0;i<n;i++)for(int j=0;j<n;j++) g[i][j] = abs(a[i].second-a[j].second);
		vector<vector<mp> > cost(n);
		for(int i=0;i<n;i++){
			cost[i] = daikus(g,i);
		}
		int m;
		cin>>m;
		/*for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<cost[i][j].first<<' ';
			}
			cout<<endl;
		}
		cout<<endl;

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<g[i][j]<<' ';
			}
			cout<<endl;
		}
		cout<<endl;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<cost[i][j].second<<' ';
			}
			cout<<endl;
		}
		cout<<endl;
		*/

		for(int i=0;i<m;i++){
			int s,t;
			cin>>s>>t;
			s = hen[s];
			t = hen[t];
			//cout<<"ok"<<s<<' '<<t<<endl;
			vector<int> kei;
			if(cost[s][t].first == inf||cost[s][t].second == n) {
				cout<<"NA"<<endl;
				continue;
			}
			kei.push_back(t);			
			while(t!=s){
		    	//cout<<t<<' '<<cost[s][t].first<<' '<<cost[s][t].second<<endl;
				t = cost[s][t].second;
				kei.push_back(t);
				//cout<<t<<endl;
			}
			//cout<<"ok"<<endl;
			cout<<a[kei[kei.size()-1]].first;
			for(int j=kei.size()-2;j>=0;j--){
				cout<<' '<<a[kei[j]].first;
			}
			cout<<endl;
		}
	}
	return 0;
}

