#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repn(i,m,n) for(int i=(m);i<=(n);i++)
#define all(n) n.begin(),n.end()
#define mp make_pair
#define PUTLINE cout<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};

double dis[1010];
string res[1010];
vector<vint> e(1010);

class Pos{
public:
	int n;
	double d;
	string s;
	bool operator>(Pos pos)const{return d>pos.d;}
};

int main() {
	int n;
	int b,x[1010],y[1010];
	while(n=in()){
		memset(x,-1,sizeof(x));
		memset(y,-1,sizeof(y));
		rep(i,1010)e[i].clear();
		rep(i,n){
			cin>>b;
			cin>>x[b]>>y[b];
		}
		repn(i,1,1000){
			if(x[i]==-1)continue;
			repn(j,1,1000){
				if(x[j]==-1)continue;
				if(i==j)continue;
				if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=2500){
					e[i].push_back(j);
				}
			}
		}
		int m=in();
		rep(i,m){
			rep(i,1010)dis[i]=100100100;
			priority_queue<Pos,vector<Pos>,greater<Pos> > que;
			Pos pos;
			pos.n=in();
			pos.d=0;
			stringstream ss;
			ss<<pos.n;
			pos.s=ss.str();
			que.push(pos);
			while(!que.empty()){
				pos=que.top();
				que.pop();
				if(dis[pos.n]<=pos.d)continue;
				dis[pos.n]=pos.d;
				res[pos.n]=pos.s;
				rep(j,e[pos.n].size()){
					Pos next;
					next.n=e[pos.n][j];
					next.d=pos.d+sqrt((double)((x[pos.n]-x[next.n])*(x[pos.n]-x[next.n])+(y[pos.n]-y[next.n])*(y[pos.n]-y[next.n])));
					ss.str("");
					ss<<next.n;
					next.s=pos.s+" "+ss.str();
					que.push(next);
				}
			}
			int g=in();
			if(dis[g]==100100100)cout<<"NA\n";
			else cout<<res[g]<<endl;
		}
	}
	return 0;
}