#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); 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 IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
#define DBL(x) ((x)*(x))

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  bool minus = false;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  if(c == '-'){
    minus = true;
    c = getchar();
  }
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  if(minus) ret *= -1;
  return ret;
}

double load[1000][1000];
bool memo[1000];
int prev[1000];
int b[1000];
int x[1000];
int y[1000];
int mapping[1001];

int main(){
  int n;
  while(n = getInt()){
    memset(mapping, -1, sizeof(mapping));
    REP(i,n){
      b[i] = getInt();
      x[i] = getInt();
      y[i] = getInt();
      mapping[b[i]] = i;
    }

    REP(i,n) REP(j,n){
      double d = sqrt(DBL(x[i]-x[j]) + DBL(y[i]-y[j]));
      load[i][j] = load[j][i] = (d <= 50 + 1e-10 ? d : 0.0);
    }

    int m = getInt();
    while(m --> 0){
      int s = mapping[getInt()];
      int g = mapping[getInt()];
      memset(memo, 0, sizeof(memo));

      if(s == -1 || g == -1){
        puts("NA");
        continue;
      }

      typedef pair<double,pair<int,int> > data;
      priority_queue<data,vector<data>,greater<data> > q;
      q.push(mp(0.0, mp(s, -1)));

      while(!q.empty()){
        double cost = q.top().f;
        int pos  = q.top().s.f;
        int ppos = q.top().s.s;

        q.pop();

        if(memo[pos]) continue;
        memo[pos] = true;
        prev[pos] = ppos;

        if(pos == g){
          vector<int> ans;
          while(pos != s){
            ans.push_back(pos);
            pos = prev[pos];
          }
          ans.push_back(s);
          for(int i=ans.size()-1; i>=0; i--)
            printf("%d%c",b[ans[i]],i==0?'\n':' ');
          break;
        }

        REP(i,n)
          if(!memo[i] && load[pos][i] != 0.0)
            q.push(mp(cost + load[pos][i], mp(i, pos)));

        if(q.empty()){
          puts("NA");
          break;
        }
      }
    }

  }
  return 0;
}