#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
using P = pair<ld, int>;
struct Edge{
    ld distance;
    int to;
    Edge(ld distance, int to) : distance(distance), to(to) {};
};
int main(){
    while(true){
        int n;
        cin >> n;
        if(!n) break;
        vector<pair<ld, ld>> coordinate(n);
        for(int i = 0; i < n; i++){
            int d, x, y;
            cin >> d >> x >> y;
            coordinate[d - 1] = make_pair(x, y);
        }
        vector<vector<Edge>> graph(n);
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                ld d = sqrt((coordinate[i].first - coordinate[j].first) * (coordinate[i].first - coordinate[j].first) + (coordinate[i].second - coordinate[j].second) * (coordinate[i].second - coordinate[j].second));
                if(d - 50 < 1e-10){
                    graph[i].emplace_back(d, j);
                    graph[j].emplace_back(d, i);
                }
            }
        }
        int m;
        cin >> m;
        vector<int> s(m), g(m);
        for(int i = 0; i < m; i++) {int a, b; cin >> a >> b; a--; b--; s[i] = a; g[i] = b;}
        for(int i = 0; i < m; i++){
            vector<P> dis(n, make_pair(1e10, -1));//距離,parent
            priority_queue<P, vector<P>, greater<P>> pq;//距離,current node
            dis[s[i]] = make_pair(0, -1);
            pq.emplace(0, s[i]);
            while(!pq.empty()){
                auto p = pq.top();
                pq.pop();
                if(p.first <= dis[p.second].first){
                    for(auto itr : graph[p.second]){
                        if(p.first + itr.distance < dis[itr.to].first){
                            dis[itr.to] = make_pair(p.first + itr.distance, p.second);
                            pq.emplace(dis[itr.to].first, itr.to);
                        }
                    }
                }
            }
            vector<int> out;
            out.push_back(g[i]);
            int pnt = g[i];
            while(true){
                auto itr = dis[pnt];
                if(itr.first > 9e9) {cout << "NA" << "\n"; break;}
                if(itr.second == -1) break;
                out.push_back(itr.second);
                pnt = itr.second;
            }
            if(out.size() != 1){
                for(int i = out.size() - 1; i >= 0; i--){
                    cout << out[i] + 1;
                    if(i != 0) cout << " "; 
                }
                cout << "\n";
            }
        }
    }
}
