#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

typedef double Weight;
const Weight INF = 1e9;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int f, int t, Weight c) :
        src(f), dst(t), weight(c) {}
};
bool operator<(const Edge &a, const Edge &b) {
    return a.weight != b.weight ? a.weight > b.weight :
        a.src != b.src ? a.src < b.src : a.dst < b.dst;
}
bool operator>(const Edge &a, const Edge &b) { return b < a; }

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int n, m;

struct Point {
    double x, y;
    Point() {}
};

void Dijkstra(const Graph &g, int s,
              vector<Weight> &dist, vector<int> &prev) {
    int n = g.size();

    dist.assign(n, INF);
    prev.assign(n, - 1);

    dist[s] = 0;
    priority_queue<Edge> que;  // e < f <=> e.weight > f.weight

    for (que.push(Edge(-2, s, 0)); !que.empty(); ) {
        Edge e = que.top();  que.pop();
        if (prev[e.dst] != -1)
            continue;

        prev[e.dst] = e.src;
        for (auto f = g[e.dst].begin(); f != g[e.dst].end(); ++f) {
            if (dist[f->dst] > e.weight + f->weight) {
                dist[f->dst] = e.weight + f->weight;
                que.push(Edge(f->src, f->dst, e.weight + f->weight));
            }
        }
    }
}

// 始点から頂点tまでの最短経路を返す
vector<int> BuildPath(const vector<int> &prev, int t) {
    vector<int> path;
    for (int u = t; u >= 0; u = prev[u])
        path.push_back(u);
    reverse(path.begin(), path.end());

    return path;
}


int main()
{
    while (cin >> n, n) {
        Graph g(n);
        vector<Weight> dist(n);
        vector<int> prev(n);
        vector<Point> pos(n);

        // Input
        for (int i = 0; i < n; ++i)
            cin >> pos[i].x >> pos[i].x >> pos[i].y;

        // Preprocessing
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j) {
                double d = (pos[i].x - pos[j].x) * (pos[i].x - pos[j].x)
                    + (pos[i].y - pos[j].y) * (pos[i].y - pos[j].y);
                d = sqrt(d);
                if (d < 50 + 1e-8) {
                    g[i].push_back(Edge(i, j, d));
                    g[j].push_back(Edge(j, i, d));
                }
            }

        cin >> m;
        int s, t;
        for (int i = 0; i < m; ++i) {
            cin >> s >> t;
            --s, --t;

            Dijkstra(g, s, dist, prev);
            if (dist[t] >= INF)
                cout << "NA\n";
            else {
                vector<int> path = BuildPath(prev, t);
                for (size_t i = 0; i < path.size() - 1; ++i)
                    cout << path[i] + 1 << " ";
                cout << path[path.size() - 1] + 1 << '\n';
            }
        }

    }

    return 0;
}