#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>

using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int N;
int b[1000],x[1000],y[1000];
vvi G;
const int INF=1e9;
void solve(int s,int g){
    queue<int>Q;
    Q.push(s);
    int D[1000];
    fill_n(D,1000,INF);
    D[s]=0;
    while(!Q.empty()){
        int pos=Q.front();Q.pop();
        rep(i,G[pos].size()){
            int to=G[pos][i];
            if(D[to]!=INF)continue;
            D[to]=D[pos]+1;
            Q.push(to);
        }
    }

    if(D[g]==INF){
        puts("NA");
        return;
    }

    vi ans;
    ans.pb(g);
    while(s!=g){
        rep(i,G[g].size()){
            int to=G[g][i];
            if(D[to]+1==D[g]){
                ans.pb(to);
                g=to;
            }
        }
    }

    reverse(all(ans));
    rep(i,ans.size()){
        if(i)printf(" ");
        printf("%d",b[ans[i]]);
    }
    puts("");
}
int main(){
    while(scanf("%d",&N),N){
        G=vvi(N);
        rep(i,N){
            scanf("%d%d%d",&b[i],&x[i],&y[i]);
            rep(j,i){
                int dis=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                if(dis>2500)continue;
                G[i].pb(j);
                G[j].pb(i);
            }
        }

        int M;
            scanf("%d",&M);
            while(M--){
                int s,g;
                scanf("%d%d",&s,&g);
                rep(i,N){
                    if(b[i]==s)s=i;
                    if(b[i]==g)g=i;
                }
                solve(s,g);
            }
    }

    return 0;
}