//* Problem  : G
//* Contest  : NEERC - 1999
//* Type     : Solution
//* Date     : 2008.06.01
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 8.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long

struct edge{
	int v1, v2, w;
};

vector <edge> a;

int X[1024], Y[1024];

int n, m, k;

int uf[1024], id[1024], sz[1024];

void init(int n)
{
	for (int i = 0; i <= n; i++)
	{
		uf[i] = id[i] = i; sz[i] = 0;
	}
}

int find(int x)
{
	while (x != id[x]) x = id[x]; return x;
}

int unite(int p, int q)
{
	int i = find(p), j = find(q);
	if (i == j) return 0;
	if (sz[i] < sz[j])
	{
		id[i] = j; sz[j] += sz[i];
	}
	else
	{
		id[j] = i; sz[i] += sz[j];
	}
	return 1;
}

int cmp(const edge &a, const edge &b)
{
	return a.w < b.w;
}

int main()
{
#ifdef _DEBUG
	freopen("A.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &X[i], &Y[i]);
	init(n);
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		int v1, v2; scanf("%d%d", &v1, &v2); unite(v1, v2);
	}
	a.resize(n * n);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			int dx = X[i] - X[j];
			int dy = Y[i] - Y[j];
			a[k].v1 = i + 1; a[k].v2 = j + 1; a[k++].w = dx * dx + dy * dy;
		}
	sort(a.begin(), a.begin() + k, cmp);
	for (int i = 0; i < k; i++)
		if (unite(a[i].v1, a[i].v2))
			printf("%d %d\n", a[i].v1, a[i].v2);
	return 0;
}
