#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<double,int> P;

const double INF = 1000000000;
struct edge { int to; double cost; };
vector<edge> G[1001];

void solve(int s, int g) {
    double d[1001]; fill(d, d+1001, INF);
    int prv[1001]; fill(prv, prv+1001, -1);
    priority_queue<P, vector<P>, greater<P> > q;
    d[s] = 0;
    q.push(make_pair(0, s));
    while ( ! q.empty()) {
        int v = q.top().second;
        q.pop();
        for (int i=0; i<(int)G[v].size(); ++i) {
            edge &e = G[v][i];
            if (e.cost != INF && d[v] + e.cost < d[e.to]) {
                d[e.to] = d[v] + e.cost;
                q.push(make_pair(d[e.to], e.to));
                prv[e.to] = v;
            }
        }
    }
    int k = g;
    if (prv[k] < 0) {
        cout << "NA" << endl;
    } else {
        vector<int> ret;
        while (0 <= k) {
            ret.push_back(k);
            k = prv[k];
        }
        for (int i=ret.size()-1; i>=0; --i) {
            cout << ret[i] << (i != 0 ? " " : "");
        }
        cout << endl;
    }
}

int main() {
    int n, m, s, g;
    int b[1000], x[1000], y[1000];
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            cin >> b[i] >> x[i] >> y[i];
        }
        for (int i=0; i<1001; ++i) {
            G[i].clear();
        }
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                int cost = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                if (2500 < cost) {
                    G[b[i]].push_back((edge){b[j], INF});
                    G[b[j]].push_back((edge){b[i], INF});
                } else {
                    G[b[i]].push_back((edge){b[j], sqrt(cost)});
                    G[b[j]].push_back((edge){b[i], sqrt(cost)});
                }
            }
        }
        cin >> m;
        for (int i=0; i<m; ++i) {
            cin >> s >> g;
            solve(s, g);
        }
    }
    return 0;
}