#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

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

void dijkstra(const Graph &g, int s,
                  vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

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;
}


typedef complex<double> P;
typedef pair<int, P> PA;

int main() {
  int n ;
  while(cin>>n,n) {
    vector<PA> v;
    map<int,int> mp;
    Graph g(n);
    REP(i,n) {
      int b,x,y;
      cin >> b >> x >> y;
      P a = P(x,y);
      REP(j,v.size()) {
        int id = (v[j]).first;
        P p = (v[j]).second;
        if (abs(a-p) <= 50) {
          g[i].push_back(Edge(i,j,abs(a-p)));
          g[j].push_back(Edge(j,i,abs(a-p)));
        }
      }
      mp[b] = i;
      v.push_back(PA(b,a));
    }
    int m;
    cin >> m;
    while(m--) {
      int s,t;
      cin >> s >> t;
      vector<int> dist, prev;
      dijkstra(g,mp[s],dist,prev);
      if (dist[mp[t]] == INF) {
        cout << "NA" << endl;
      } else {
        vector<int> path = buildPath(prev,mp[t]);
        REP(i,path.size()) {
          if (i) cout << " ";
          cout << v[path[i]].first;
        }
        cout << endl;
      }
    }
    
  }
}