#include <bits/stdc++.h>
#define INF 1000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
double G[101][101];

void dijkstra(int s,int g){
  int cost[101]={};
  memset(cost,-1,sizeof(cost));
  cost[s]=0;
  int from[101]={};
  queue<int> Q;
  Q.push(s);
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    
    for(int i=0;i<n;i++){
      if(G[pos][i]==0||cost[i]!=-1)continue;
      Q.push(i);
      cost[i]=cost[pos]+1;
      from[i]=pos;
    }
  }
  
  vector<int> res;
  res.push_back(g);
  int pos=g;
  while(pos!=s){
    pos=from[pos];
    res.push_back(pos);
  }

  for(int i=0;i<res.size();i++){
    if(i) cout<<" ";
    cout<<res[res.size()-1-i]+1;
  }
  cout<<endl;
}


int main(){
  while(cin>>n,n){
    double x[101],y[101];
    for(int i=0;i<n;i++){
      int b;
      cin>>b;
      cin>>x[b-1]>>y[b-1];
    }
    
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	ll X=(x[i]-x[j]);
	ll Y=(y[i]-y[j]);
	ll dis=X*X+Y*Y;
	G[i][j]=G[j][i]=(dis<=50*50);
      }

    int m;
    cin>>m;
    while(m--){
      int s,g;
      cin>>s>>g;
      dijkstra(s-1,g-1);
    }
  }
  return 0;
}