#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

typedef double Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

double const inf = 1e100;
void dijk(Graph const&g, int s, vector<Weight> &dist, vi &prev) {
    int n = g.size();
    dist.assign(n, inf); dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> q; // "e < f" <=> "e.weight > f.weight"
    q.push(Edge(-2, s, 0));
    while(q.size()) {
        Edge e = q.top();
        q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        for(auto f : g[e.dst]) {
            if (dist[f.dst] > e.weight+f.weight) {
                if(f.weight > 50) continue;
                dist[f.dst] = e.weight+f.weight;
                q.push(Edge(f.src, f.dst, e.weight+f.weight));
            }
        }
    }
}

vi buildPath(vi const& prev, int t) {
    vi path;
    for (int u = t; u >= 0; u = prev[u])
        path.push_back(u);
    reverse(all(path));
    return path;
}


int main(){
    int n;
    while(cin >> n && n){
        map<int,pair<int,int>> m;
        rep(i,n){
            int b;
            double x,y;
            cin >> b >> x >> y;
            m[b] = mp(x,y);
        }
        Graph g(m.rbegin()->first + 10);
        rep(i,g.size())rep(j,g.size()){
            double dx = m[i].first - m[j].first;
            double dy = m[i].second - m[j].second;
            double dist = sqrt(dx*dx + dy*dy);
            g[i].eb(i,j,dist);
        }
        int t;
        cin >> t;
        rep(i,t){
            int s1,g1;
            cin >> s1 >> g1;
            dump(s1,g1);
            vector<Weight> dist;
            vector<int> prev;
            dijk(g,s1,dist,prev);
            if(dist[g1]==inf){
                cout << "NA" << endl;
            } else {
                vi ans = buildPath(prev,g1);
                rep(i,ans.size()){
                    cout << ans[i];
                    cout << (i+1==(int)ans.size() ? "\n" : " ");
                }
            }
        }
    }
}

Measured memory_bytes: 1396