//45
#include<iostream>
#include<cmath>

#define S(X) ((X)*(X))

using namespace std;

int main(){
  int px[1001],py[1001],bn[1001],ni[1001];
  for(int n;cin>>n,n;){
    for(int i=0;i<n;i++){
      cin>>bn[i]>>px[i]>>py[i];
      ni[bn[i]]=i;
    }
    int m;
    cin>>m;
    while(m--){
      int s,g;
      cin>>s>>g;
      int p[1001];
      double d[1001];
      fill(p,p+1001,-1);
      fill(d,d+1001,1<<29);
      bool u[1001]={};
      d[ni[g]]=0;
      for(;;){
	int x,md=1<<29;
	for(int j=0;j<n;j++){
	  if(!u[j]&&md>d[j]){
	    x=j;
	    md=d[j];
	  }
	}
	if(md==1<<29)break;
	u[x]=true;
	for(int i=0;i<n;i++){
	  double ds=sqrt(S(px[x]-px[i])+S(py[x]-py[i]));
	  if(ds<=50&&d[x]+ds<d[i]){
	    d[i]=d[x]+ds;
	    p[i]=x;
	  }
	}
      }
      if(d[ni[s]]==1<<29){
	cout<<"NA"<<endl;
      }else{
	int i=ni[s];
	while(i!=-1){
	  cout<<((i==ni[s])?"":" ")<<bn[i];
	  i=p[i];
	}
	cout<<endl;
      }
    }
  }
  return 0;
}