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

using namespace std;

const double EPS = 1e-10;
const double INF = 100000000.0;

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

map<int, int> idToIdx;
map<int, int> idxToId;
B buildings[1000];
int n, m;
int s, t;
vector<int> G[1000];
int prev[1000];
double dist[1000];
bool used[1000];

priority_queue<P, vector<P>, greater<P> > que;

double getDistance(B a, B b){
  //cout << a << ' ' << b << ' ' << abs(a-b) << endl;
  return abs(a-b);
}

void addEdge(int a, int b){
  G[a].push_back(b);
  G[b].push_back(a);
}

void makeGraph(){
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(getDistance(buildings[i], buildings[j]) < 50.0 + EPS) addEdge(i, j);
    }
  }
}

void dijkstra(){
  fill(dist, dist+n, INF);
  fill(prev, prev+n, -1);
  dist[s] = 0.0;
  que.push(make_pair(0.0, s));

  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      if(dist[G[v][i]] > dist[v] + getDistance(buildings[v], buildings[G[v][i]])){
	dist[G[v][i]] = dist[v] + getDistance(buildings[v], buildings[G[v][i]]);
	prev[G[v][i]] = v;
	//cout << "!" << getDistance(v, G[v][i]) << endl;
	que.push(make_pair(dist[G[v][i]], G[v][i]));
      }
    }
  }
}

void traverse(){
  vector<int> path;
  if(prev[t] == -1){
    cout << "NA" << endl;
    return;
  }
  for(;t!=-1;t=prev[t]) path.push_back(t);
  reverse(path.begin(), path.end());
  cout << idxToId[path[0]];
  for(int i=1;i<path.size();i++){
    cout << ' ' << idxToId[path[i]];
  }
  cout << endl;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      G[i].clear();
    }
    idToIdx.clear();
    idxToId.clear();
    for(int i=0;i<n;i++){
      int id;
      cin >> id >> buildings[i].real() >> buildings[i].imag();
      idToIdx[id] = i;
      idxToId[i] = id;
    }
    makeGraph();
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> s >> t;
      s = idToIdx[s];
      t = idToIdx[t];
      dijkstra();
      for(int i=0;i<n;i++){
	//cout << dist[i] << endl;
      }
      traverse();
    }
  }
  return 0;
}