#include<iostream>
#include<cstdio>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>

using namespace std;

int n,m;
struct bill{
	int b,x,y;
	bill(int b,int x,int y):b(b),x(x),y(y){};
};
vector<bill> bi;
map<int,int> bn;
map<int,int> bnb;
typedef pair<double,int> P;
double d[10000];
int pr[10000];
double INF=10000000;

double sqr(int num){
	return sqrt((double)num);
}

int po2(int l){
	return l*l;
}

void dijk(int f,int t){
	fill(d,d+n+1,INF);
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0.0,f));
	d[f]=0.0;
	while(que.size()){
		P p=que.top();
		que.pop();
		double c=p.first;
		int v=p.second;
		if(d[v]<c)continue;
		for(int i=0;i<n;i++){
			double k=sqr(po2(abs(bi[v].x-bi[i].x))+po2(abs(bi[v].y-bi[i].y)));
			if(k<=50.0 && d[i]>c+k){
				d[i]=c+k;
				pr[i]=v;
				que.push(P(c+k,i));
			}
		}
	}
}

void rc(int f,int t){
	vector<int> prev;
	while(f!=t){
		prev.push_back(bnb[t]);
		t=pr[t];
	}
	prev.push_back(bnb[t]);
	sort(prev.begin(),prev.end());
	for(int i=0;i<prev.size();i++){
		if(i!=0)printf(" ");
		printf("%d",prev[i]);
	}
	printf("\n");
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		bi.clear();
		bn.clear();
		bnb.clear();
		for(int i=0;i<n;i++){
			int b,x,y;
			scanf("%d%d%d",&b,&x,&y);
			bi.push_back(bill(b,x,y));
			bn[b]=i;
			bnb[i]=b;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			int f,t;
			scanf("%d%d",&f,&t);
			dijk(bn[f],bn[t]);
			if(d[bn[t]]!=INF)rc(bn[f],bn[t]);
			else printf("NA\n");
		}
	}
	return 0;
}