// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-6
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
using namespace std;
// mylittledoge
typedef long double dbl;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
vector< pair<int,int> > T(N);
for(int i =0; i < N; i++) cin >> T[i].ff >> T[i].ss;
vector< vector<int> > G(N);
int M;
cin >> M;
for(int i =0; i < M; i++) {
int a,b;
cin >> a >> b;
G[--a].push_back(--b);
G[b].push_back(a);}
vector<bool> F(N,true);
vector<dbl> D(N,1e10);
vector<int> ako(N,0);
F[0] =false;
for(int i =1; i < N; i++) D[i] =sqrt(1.0L*(T[i].ff-T[0].ff)*(T[i].ff-T[0].ff)+1.0L*(T[i].ss-T[0].ss)*(T[i].ss-T[0].ss));
ALL_THE(G[0],it) D[*it] =0;
vector< pair<int,int> > ans;
for(int i =1; i < N; i++) {
int x =0;
dbl d =1e10;
for(int j =1; j < N; j++) if(F[j] && D[j] < d) {
d =D[j];
x =j;}
if(d > 0.5) ans.push_back(make_pair(x+1,ako[x]+1));
F[x] =false;
ALL_THE(G[x],it) D[*it] =0, ako[*it] =x;
for(int j =1; j < N; j++) if(F[j]) {
d =sqrt(1.0L*(T[j].ff-T[x].ff)*(T[j].ff-T[x].ff)+1.0L*(T[j].ss-T[x].ss)*(T[j].ss-T[x].ss));
if(d < D[j]) D[j] =d, ako[j] =x;}
}
ALL_THE(ans,it) cout << it->ff << " " << it->ss << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW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