#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<double,int> pii;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pii> vp;
typedef vector<pdd> vdd;
typedef vector<pair<double,int> >vdi;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class DIJ{
    public:
    struct edge{
        int to;
        double cost;
    };
    vector<vector<edge> >G;
    int n;
    vector<double> d;//distance
    DIJ(int size){
        n=size;
        G=vector<vector<edge> >(n);
    }
    void add_edge(int a,int b,double c){
        edge e={b,c},ee={a,c};
        G[a].pb(e);
        G[b].pb(ee);
    }
    void dij(int s){
        d=vector<double>(n,inf);
        d[s]=0;
        priority_queue<pii>q;
        q.push(pii(0,s));
        while(!q.empty()){
            pii p=q.top();
            q.pop();
            int pos=p.second;
            double cost=-p.first;
            if(cost>d[pos])continue;
            rep(i,G[pos].size()){
                edge e=G[pos][i];
                int to=e.to;
                double nowcost=cost+e.cost;
                if(nowcost<d[to]){
                    d[to]=nowcost;
                    q.push(pii(-d[to],to));
                }
            }
        }
    }
};
int main(){
    int n;
    while(cin>>n,n){
        vi m(n);
		map<int,int>M;
        vector<pair<int,int> > in(n);
        rep(i,n){
            int a,b,c;
            cin>>a>>b>>c;
            m[i]=a;
			M[a]=i;
            in[i]=pair<int,int>(b,c);
        }
        DIJ dij(n);
        rep(i,n)rep(j,i)if(i!=j&&(in[i].first-in[j].first)*(in[i].first-in[j].first)+(in[i].second-in[j].second)*(in[i].second-in[j].second)<EPS+50*50)
			dij.add_edge(i,j,hypot(in[i].first-in[j].first,in[i].second-in[j].second));
        int N;
        cin>>N;
        while(N--){
            int a,b;
            cin>>a>>b;
			a=M[a];b=M[b];
            dij.dij(a);
            if(abs(dij.d[b]-inf)<EPS)cout<<"NA"<<endl;
            else{
                vi out;
                out.pb(b);
                int t=b;
                while(1){
                    rep(i,n)rep(j,dij.G[i].size()){
                        if(t==dij.G[i][j].to&&abs(dij.d[i]+dij.G[i][j].cost-dij.d[t])<EPS){
                            out.pb(i);
                            t=i;
                            goto end;
                        }
                    }
                    end:;
                    if(out[out.size()-1]==a)break;
                }
                for(int i=out.size()-1;i>=0;i--)cout<<m[out[i]]<<(i?" ":"\n");
            }
        }
    }
}

Measured memory_bytes: 1252