#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P complex<double>
#define Y real()
#define X imag()
const double INF = (1 << 16);
const int N = 1010;

class C{
  public:
    double dis;
    int now;
    vector<int> visited;
    C(double _d, int _n, vector<int> _v){
      dis = _d;
      now = _n;
      visited = _v;
    }
    bool operator>(const C &c) const { return dis > c.dis; }
};

int main() {
  int n;
  while(cin >>n && n){
    vector< pair<int, P> > building(n);
    REP(i, n){
      int a, b;
      cin >>building[i].first >>a >>b;
      building[i].second = P(a, b);
    }
    vector< vector<double> > v(N, vector<double>(N, INF));
    REP(i, n){
      REP(j, n){
        double d = abs(building[i].second - building[j].second);
        if(d <= 50.0) v[building[i].first][building[j].first] = d;
      }
    }

    int m; cin >>m;
    REP(z, m){
      int s, g; cin >>s >>g;
      priority_queue<C, vector<C>, greater<C> > open;
      vector<int> tmp(N, INF);
      tmp[s] = 0;
      open.push( C(0.0, s, tmp) );
      vector<double> closed(N, INF);
      C ans = C(0.0, -1, vector<int>());

      while(!open.empty()){
        C now = open.top();
        open.pop();

        //debug
        //cout <<now.dis <<", " <<now.now <<", ";
        //REP(i, N) REP(j, N) if(now.visited[j] == i) cout <<j <<" ";
        //cout <<endl <<"---------" <<endl;

        if(now.now == g){
          ans = now;
          break;
        }
        if(closed[now.now] <= now.dis) continue;
        closed[now.now] = now.dis;

        REP(i, N){
          if(now.visited[i] != INF || v[now.now][i] == INF) continue;
          now.visited[i] = now.dis + v[now.now][i];
          open.push( C(now.dis + v[now.now][i], i, now.visited) );
          now.visited[i] = INF;
        }
      }

      if(ans.now == -1) cout <<"NA" <<endl;
      else{
        vector<int> ans_v;
        REP(i, N) REP(j, N) if(ans.visited[j] == i) ans_v.push_back(j);
        cout <<ans_v[0];
        FOR(i, 1, ans_v.size()) cout <<" " <<ans_v[i];
        cout <<endl;
      }

    }
  }
  return 0;
}