#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>

int main(){
    while (true){
    int n;
    cin >> n;
    if (n==0) return 0;
    vector<pp> a(n+1);
    for (int i=1;i<n+1;i++){
        int h;
        cin >> h;
        cin >> a.at(h).first >> a.at(h).second;
    }
    vector<vector<pair<int,double>>> d(n+1,vector<pair<int,double>>(0));
    pair<int,double> v;
    for (int i=1;i<n+1;i++){
        for (int j=1;j<n+1;j++){
            if (i==j) continue;
            if ((a.at(i).first-a.at(j).first)*(a.at(i).first-a.at(j).first)+(a.at(i).second-a.at(j).second)*(a.at(i).second-a.at(j).second)>2500) continue;
            double yyyy=(a.at(i).first-a.at(j).first)*(a.at(i).first-a.at(j).first)+(a.at(i).second-a.at(j).second)*(a.at(i).second-a.at(j).second);
            v.second=sqrt(yyyy);v.first=j;
            d.at(i).push_back(v);
        }
    }
    int t;
    cin >> t;
    queue<int> q;
    
    
    for (int i=0;i<t;i++){
        vector<double> df(n+1);
        vector<vector<int>> r(n+1,vector<int>(0));
        for (int j=1;j<n+1;j++){
            df.at(j)=10000000;
        }
        int aa,bb;
        cin >> aa >> bb;
        q.push(aa);
        df.at(aa)=0;
        while(!q.empty()){
            int ii=q.front();
            q.pop();
            for (int j=0;j<d.at(ii).size();j++){
                int w=d.at(ii).at(j).first;
                double ww=d.at(ii).at(j).second;
                if (df.at(ii)+ww<df.at(w)) {
                    df.at(w)=df.at(ii)+ww;
                    q.push(w);
                    r.at(w)=r.at(ii);
                    r.at(w).push_back(ii);
                }
            }
        }
        if (r.at(bb).size()==0) cout << "NA" << endl;
        else {
            for (int j=0;j<r.at(bb).size();j++){
                cout << r.at(bb).at(j) << " ";
            }
            cout << bb << endl;
        }
    }
    }}
