#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <stack>
using namespace std;

const int INF = 1<<28;

struct Edge {
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
    bool operator<(const Edge &o) const {
        return (cost < o.cost);
    }
    bool operator>(const Edge &o) const {
        return (cost > o.cost);
    }
};
struct State {
    int v;
    int min_cost;
    State(int v, int min_cost) : v(v), min_cost(min_cost) {}
    bool operator<(const State &o) const {
        return (min_cost < o.min_cost);
    }
    bool operator>(const State &o) const {
        return (min_cost > o.min_cost);
    }
};
typedef vector<Edge> Vertex;
struct Graph {
    vector<Vertex> g;

    Graph() {}

    Graph(int vertex_count) : g(vertex_count) {}
    Graph(vector<Vertex> g) : g(g) {}

    inline Vertex& operator[](int index) {
        return g[index];
    }

    inline void add_vertex(Vertex v) {
        g.push_back(v);
    }

    inline void add_edge(int from, int to, double cost) {
        g[from].push_back(Edge(from, to, cost));
    }
    
    void min_path(int s, vector<int>& min_cost, vector<int> &prev_v) {
        min_cost.resize(g.size());
        prev_v.resize(g.size());
        fill(prev_v.begin(), prev_v.end(), -1);
        priority_queue< State, vector<State>, greater<State> > q;
        
        fill(min_cost.begin(), min_cost.end(), INF);

        min_cost[s] = 0;
        q.push(State(s, 0));

        while (!q.empty()) {
            State p = q.top(); q.pop();
            int v = p.v;
            if (min_cost[v] < p.min_cost) continue;
            for (int i = 0; i < g[v].size(); i++) {
                Edge e = g[v][i];
                if (min_cost[e.to] > min_cost[v] + e.cost)  {
                    min_cost[e.to] = min_cost[v] + e.cost;
                    prev_v[e.to] = e.from;
                    q.push(State(e.to, min_cost[e.to]));
                }
            }
        }
    }
};

#define MAX_N 1001

struct Bill {
    int b, x, y;
    double dist(const Bill &o) const {
        double dx = x - o.x;
        double dy = y - o.y;
        return sqrt(dx*dx+dy*dy);
    }
};

int main() {
    int n;
    while (cin >> n, n != 0) {
        Graph g(MAX_N);
        vector<Bill> pos;
        for (int i = 0; i < n; i++) {
            Bill b;
            cin >> b.b >> b.x >> b.y;
            pos.push_back(b);
        }
        for (int i = 0; i < pos.size(); i++) {
            for (int j = 0; j < pos.size(); j++) {
                double d = pos[i].dist(pos[j]);
                if (d <= 50) g.add_edge(pos[i].b, pos[j].b, d);
            }
        }
        int m; cin >> m;
        for (int i = 0; i < m; i++) {
            int s, _g; cin >> s >> _g;
            vector<int> prev_v;
            vector<int> min_cost;
            g.min_path(s, min_cost, prev_v);
            if (min_cost[_g] == INF) cout << "NA" << endl;
            else {
                stack<int> st;
                st.push(_g);
                while (prev_v[_g] != -1) {
                    st.push(prev_v[_g]);
                    _g = prev_v[_g];
                }

                cout << st.top(); st.pop();
                while (!st.empty()) {
                    cout << ' ';
                    cout << st.top();
                    st.pop();
                }
                cout << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1252