#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










using P = pair<double, ll>;

int main() {
    ll n;
    while(cin >> n, n){
        vector<ll> b(n);
        vector<double> x(n), y(n);
        REP(i, n){
            cin >> b[i] >> x[i] >> y[i];
            b[i]--;
        }
        
        vector<vector<P>> g(n);
        REP(i, n){
            REP(j, n){
                if(i == j) continue;
                
                double d = sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
                if(d <= 50.0){
                    g[b[i]].push_back({d, b[j]});
                    g[b[j]].push_back({d, b[i]});
                }
            }
        }
        
        ll m;
        cin >> m;
        REP(i, m){
            ll S, G;
            cin >> S >> G;
            S--; G--;
            
            vector<double> dist(n, INF);
            dist[S] = 0;
            vector<ll> prev(n);
            priority_queue<P, vector<P>, greater<P>> que;
            que.push({0, S});
            while(!que.empty()){
                auto tmp = que.top(); que.pop();
                double d = tmp.first;
                ll now = tmp.second;
                if(dist[now] < d) continue;
                
                for(auto &x : g[now]){
                    double cost = d + x.first;
                    ll v = x.second;
                    if(dist[v] > cost){
                        dist[v] = cost;
                        prev[v] = now;
                        que.push({cost, v});
                    }
                }
            }
            
            if(dist[G] == INF){
                cout << "NA" << endl;
                continue;
            }
            
            vector<ll> ans;
            for(ll v = G; v != S; v = prev[v]){
                ans.push_back(v + 1);
            }
            ans.push_back(S + 1);
            reverse(ans.begin(), ans.end());
            REP(i, ans.size()){
                cout << ans[i] << " \n"[i == ans.size() - 1];
            }
        }
    }
}

