#include <iostream>
#include <stdlib.h>
#include <math.h>
#define inf 99999.0

using namespace std;

bool check(int *label, int n)
{
	for(int i = 1; i <= n; i++){
		if(label[i] == 0){
			return true;
		}
	}
	
	return false;
}

void dij(float **a, int n, int s, int t)
{
	int *label, current=s, num=1, next, *ne;
	float *cost, min;
	
	cost = (float *)calloc(n+1, sizeof(float));
	label = (int *)calloc(n+1, sizeof(int));
	ne = (int *)calloc(n+1, sizeof(int));
	
	for(int i = 1; i <= n; i++){
		cost[i] = a[current][i];
		if(a[current][i] != inf){
			ne[i] = s;
		}
	}
	label[current] = num++;
	
	while(check(label, n)){
		min = inf;
		for(int i = 1; i <= n; i++){
			if(min >= cost[i] && label[i] == 0){
				min = cost[i];
				next = i;
			}
		}
		label[next] = num++;
		for(int i = 1; i <= n; i++){
			if(label[i] == 0 && cost[i] > (a[next][i]+cost[next])){
				cost[i] = a[next][i] + cost[next];
				ne[i] = next;
			}
		}
		current = next;
	}

	if(ne[t] == 0){
		cout << "NA" << endl;
	} else {
		free(label);
		label = (int *)calloc(n+1, sizeof(int));
		label[0] = t;
		next = ne[t];
		current = 1;
		while(ne[next] != next){
			label[current++] = next;
			next = ne[next];
		}
		label[current] = next;
		for(int i = current; i > 0; i--){
			cout << label[i] << " ";
		}
		cout << t << endl;
	}
	
	free(ne);
	free(cost);
	free(label);
	
	return ;
}

int main(int argc, char **argv)
{
	float **a, *x, *y;
	int n, m, s, t, bn;
		
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = (float **)calloc(n+1, sizeof(float));
		x = (float *)calloc(n+1, sizeof(float));
		y = (float *)calloc(n+1, sizeof(float));
		
		for(int i = 1; i <= n; i++){
			a[i] = (float *)calloc(n+1, sizeof(float));
			cin >> bn;
			cin >> x[bn] >> y[bn];
		}
		cin >> m;
		
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				a[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
				if(a[i][j] > 50.0){
					a[i][j] = inf;
				}
			}
		}
		for(int i = 0; i < m; i++){
			cin >> s >> t;
			dij(a, n, s, t);
		}
		
		for(int i = 0; i <= n; i++){
			free(a[i]);
		}
		free(a);
		free(x);
		free(y);
	}
	
	return 0;
}