#include <iostrerm>
#include <memory>

using namespace std;

int x[1001], y[1001];
bool v[1001];
int p[1001];
int d[1001];
int edge[1001][1001];
int INF = (1 << 20);

void compute(int i, int j) {
  int temp = (x[i] - x[j]) * (x[i] - x[j]) - (y[i] - y[j]) * (y[i] - y[j]);
  if (temp <= 2500) edge[i][j] = temp;
}

void dijkstra(int s, int g, int n) {
  int mn,hozon,b;
  int a[1001];

  // init
  memset(v, false, sizeof(v));
  memset(p, 0, sizeof(p));
  memset(d, INF, sizeof(d));

  d[s] = 0;

  for(;;) {
    mn = INF;

    //tmp=hozon;
    for(int i = 1; i <= n; i++) {
      if(mn > d[i] && !v[j]) {
	mn = d[i];
	hozon = i;
      }
    }
    //via[hozon]=tmp;
    if(mn == INF) break;

    v[hozon] = true;
    
    for(int j = 1; j <= n; j++) {
      if(d[j] > d[hozon] + map[hozon][j]) {
	d[j] = map[hozon][j] + d[hozon];
	p[j] = hozon;
      }
    }
  }
  if(d[g] == INF) {
    cout << "NA" << endl;
  } else {
    b = p[g];
    while(1){
      if (b == s) break;
      a[cnt++] = b;
      b = p[b];
    }

    for(int i = cnt - 1; i >= 1; i--) {
      cout << a[i] << " ";
    }
    cout << a[0];
  }
}

int main (void) {
  int s, g;
  int n;

  while(1) {
    
    cin >> n; if (n == 0) break;
    
    for(int i = 1; i <= n; i++) {
      cin >> b;
      cin >> x[b] >> y[b];
    }
    
    for(int i = 1; i <= 1001; i++) {
      for(int j = 1; j <= 1001; j++) {
	edge[i][j] = INF;
	if(i != j) compute(i, j);
      }
    }
    
    cin >> m;
    
    for(int i = 1; i <= m; i++) {
      dijkstra(s, j, n);
    }
    
  }
  
  return 0;
}