#include "iostream"
#include "vector"
#include "cmath"
#include "queue"
using namespace std;
const int N = 1e3;
const double INF = 1e10;
struct dist{
int x;
double l;
};
priority_queue<dist> qu;
bool operator < (const dist d1,const dist d2){
return d1.l > d2.l;
}
struct edge{
int to;//指向哪个点
double w;//权值:长度
};
vector<edge> graph[N];
struct node{
int x,y;
}nodes[N];
int n,m,s,t;//n个节点,m条边
double dis[N];
int flag[N];
void addEdge(int from,int to);
void dijkstra(int x);
int main(){
cin>>n;
int x,y;
for(int i=1;i<=n;i++){
cin>>x>>y;
nodes[i].x = x;
nodes[i].y = y;
}
cin>>m;
int from,to;
for(int i = 1;i <= m;i++){
cin>>from>>to;
addEdge(from,to);
}
// //遍历看
// for(int i = 1; i <=n ;i++){
// cout<<"节点"<<i<<":"<<endl;
// for(int j = 0;j < graph[i].size();j ++){
// cout<<"("<<graph[i][j].to<<" "<<g