#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <cmath>
using namespace std;

struct Node {
    bool isDone;
    int x, y, cost, from, dist2Next;
};

const int INF = pow(2, 30);
const int MAX_N = 1000;
Node nodes[MAX_N + 1];
int n;

void dijkstra(int start, int end) {
    for (int i = 1; i <= n; i++) {
        nodes[i].isDone = false;
        nodes[i].cost = -1;
        nodes[i].from = -1;
        nodes[i].dist2Next = INF;
    }
    nodes[start].cost = 0;
    nodes[start].from = 0;
    while (true) {
        queue<int> qu;
        for (int i = 1; i <= n; i++) {
            if (nodes[i].isDone == true || nodes[i].cost < 0) {
                continue;
            }
            qu.push(i);
        }
        if (qu.empty() == true) {
            break;
        }
        vector<int> dist2Next(n + 1, INF);
        while (qu.empty() == false) {
            int idx = qu.front();
            qu.pop();
            nodes[idx].isDone = true;
            int cost = nodes[idx].cost + 1;
            for (int i = 1; i <= n; i++) {
                int dist2 = pow(nodes[i].x - nodes[idx].x, 2) + pow(nodes[i].y - nodes[idx].y, 2);
                if (nodes[i].isDone == true || dist2 > pow(50, 2)) {
                    continue;
                }
                if (nodes[i].cost < 0 || cost < nodes[i].cost
                    || (cost == nodes[i].cost && dist2 < dist2Next[i])) {
                    nodes[i].cost = cost;
                    nodes[i].from = idx;
                    dist2Next[i] = dist2;
                }
            }
        }
    }
}

int main() {
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            int b, x, y;
            cin >> b >> x >> y;
            nodes[b].x = x;
            nodes[b].y = y;
        }
        int m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int s, g;
            cin >> s >> g;
            dijkstra(s, g);
            string result;
            if (nodes[g].cost < 0) {
                result = "NA";
            } else {
                stringstream ss;
                ss << g;
                ss >> result;
                int from = nodes[g].from;
                while (from > 0) {
                    stringstream ss;
                    ss << from;
                    string temp;
                    ss >> temp;
                    result = temp + " " + result;
                    from = nodes[from].from;
                }
            }
            cout << result << endl;
        }
    }
}