#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int b[2000]={},x[2000]={},y[2000]={};
        rep(i,n){
            cin>>b[i]>>x[i]>>y[i];
            b[i]--;
        }
        
        double data[200][200]={};
        rep(i,n) rep(j,n) data[i][j]=99999999;
        int prev[200][200]={};

        rep(i,n){
            rep(j,n){
                double res=sqrt( pow(x[i]-x[j],2) + pow(y[i]-y[j],2) );
                if(res<=50.0){
                    data[i][j]=res;
                    prev[i][j]=i;
                }
            }
        }
        
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    if( data[i][k]+data[k][j] < data[i][j] ){
                        data[i][j] = data[i][k]+data[k][j];
                        prev[i][j]=prev[k][j];
                    }
                    data[i][j]=min( data[i][k]+data[k][j] , data[i][j] );
                }
            }
        }
        
        int m;
        cin>>m;
        
        int s,g;
        rep(i,m){
            cin>>s>>g;
            s--,g--;
            if(data[s][g]!=99999999){
                stack<int> ans;
                int pre=g;
                while(pre!=s){
                    ans.push(pre);
                    pre=prev[s][pre];
                }
                cout<<s+1;
                while(ans.size()){
                    cout<<" "<<ans.top()+1;
                    ans.pop();
                }
                cout<<endl;
            }
            else cout<<"NA"<<endl;
        }
    }
    return 0;
}