#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <ostream>
using namespace std;

template <typename T>
struct Edge { int src, dst; T cost;
    Edge(int dst, T cost) : src(-1), dst(dst), cost(cost) { }
    Edge(int src, int dst, T cost) : src(src), dst(dst), cost(cost) { }
};
template <typename T> using Edges = vector<Edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
pair<vector<T>, vector<int>> dijkstra(const WeightedGraph<T> &g, int s) {
    const T INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);
    vector<int> prev(g.size(), -1);
    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0; que.emplace(dist[s], s);
    while (!que.empty()) {
        T cost; int u; tie(cost, u) = que.top(); que.pop();
        if (dist[u] < cost) continue;
        for (auto &e: g[u]) {
            int v = e.dst; T nc = e.cost;
            if (dist[v] <= dist[u] + nc) continue;
            dist[v] = dist[u] + nc; prev[v] = u;
            que.emplace(dist[v], v);
        }
    }
    return {dist, prev};
}
template <typename T>
vector<int> build_path(vector<T> &dist, vector<int> &prev, int t) {
    const T INF = numeric_limits<T>::max();
    if (dist[t] == INF) return {};
    vector<int> path;
    for (int u = t; u >= 0; u = prev[u]) path.emplace_back(u);
    reverse(path.begin(), path.end());
    return path;
}


#include <cmath>
template<class T> T dist2(T x, T y) { return x * x + y * y; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
int main() {
    int n;
    while (cin >> n, n) {
        WeightedGraph<double> g(n + 1);
        vector<int> b(n), x(n), y(n);
        for (int i = 0; i < n; i++) cin >> b[i] >> x[i] >> y[i];
        for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) {
            int d2 = dist2(x[i] - x[j], y[i] - y[j]);
            if (d2 <= 50 * 50) {
                g[b[i]].emplace_back(b[j], sqrt(d2));
                g[b[j]].emplace_back(b[i], sqrt(d2));
            }
        }
        int m; cin >> m;
        while (m--) {
            int ss, gg; cin >> ss >> gg;
            vector<double> dist;
            vector<int> prev;
            tie(dist, prev) = dijkstra(g, ss);
            auto res = build_path(dist, prev, gg);
            if (res.empty()) {
                cout << "NA" << endl;
            } else {
                for (int i = 0; i < res.size(); i++) cout << res[i] << " \n"[i == res.size() - 1];
            }
        }
    }
    return 0;
}
