#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
double pi = acos(-1.);
struct cd {
  double a, b;
  cd() {}
  cd(double a, double b) : a(a), b(b) {}
  cd operator+(const cd &y) const { return (cd){a + y.a, b + y.b}; }
  cd operator-(const cd &y) const { return (cd){a - y.a, b - y.b}; }
  cd operator*(const cd &y) const {
    return (cd){a * y.a - b * y.b, a * y.b + b * y.a};
  }
  cd operator!() const { return (cd){a, -b}; };
  double len() { return a * a + b * b; }
};
bool operator<(cd a, cd b) { return a.a < b.a; }
const int N = 101000;
int n, n1, n2;
cd p[N], q1[N], r1[N], q2[N], r2[N];
cd gen() {
  return cd(rand() % 200000001 * 1e-4 - 10000,
            rand() % 200000001 * 1e-4 - 10000);
}
cd ang(double x) { return cd(cos(x), sin(x)); }
cd rrrrrd(cd p) {
  double x = p.a, y = p.b;
  x = floor(x * 100 + 0.5) * 0.01, y = floor(y * 100 + 0.5) * 0.01;
  return cd(x, y);
}
double eval(cd p, cd *q, int n) {
  double mxx = -1e6, mnx = 1e6, mxy = -1e6, mny = 1e6;
  for (int i = 0; i < n; i++) {
    cd z = q[i] * p;
    mxx = max(mxx, z.a);
    mxy = max(mxy, z.b);
    mnx = min(mnx, z.a);
    mny = min(mny, z.b);
  }
  return mxx + mxy - mnx - mny;
}
void recov(cd *q, cd *r, cd p, int n) {
  double mxx = -1e6, mnx = 1e6, mxy = -1e6, mny = 1e6;
  for (int i = 0; i < n; i++) {
    cd z = q[i] * p;
    mxx = max(mxx, z.a);
    mxy = max(mxy, z.b);
    mnx = min(mnx, z.a);
    mny = min(mny, z.b);
    r[i] = z;
  }
  cd d(-0.5 * (mxx + mnx), -0.5 * (mxy + mny));
  for (int i = 0; i < n; i++) r[i] = r[i] + d;
}
void gao(cd *q, cd *r, int n) {
  double vl = 0, vr = pi / 2;
  for (int i = 0; i < 50; i++) {
    double fl = (vl + vl + vr) / 3, fr = (vl + vr + vr) / 3;
    if (eval(ang(-fl), q, n) > eval(ang(-fr), q, n))
      vl = fl;
    else
      vr = fr;
  }
  recov(q, r, ang(-vl), n);
}
void gen(int n, cd *p, int &n2, cd *q) {
  n2 = n + rand() % (n / 2 + 1);
  for (int i = 0; i < n; i++) q[i] = p[i];
  for (int i = n; i < n2; i++) q[i] = gen();
  double t = rand() % 100000000 * 2e-8 * pi;
  cd c = ang(t);
  cd d = gen();
  for (int i = 0; i < n2; i++) q[i] = rrrrrd(q[i] * c + d);
}
int rk[N], vis1[N], vis2[N], perm[N], mat[N];
cd pnt[N];
pair<int, int> pr[4][N];
double ret[4], dd[N];
void match(cd *r1, cd *r2, int n1, int n2, int n, pair<int, int> *pr,
           double &ret) {
  for (int i = 0; i < n1; i++) rk[i] = i, vis1[i] = 0;
  sort(rk, rk + n1, [&](int a, int b) { return r1[a] < r1[b]; });
  for (int i = 0; i < n1; i++) pnt[i] = r1[rk[i]];
  for (int i = 0; i < n2; i++) {
    int z = lower_bound(pnt, pnt + n1, r2[i]) - pnt;
    double dis = 1e10;
    int pv = -1;
    for (int j = 0; j < 100; j++) {
      bool fd = 0;
      if (z + j < n1 && pnt[z + j].a <= r2[i].a + dis) {
        fd = 1;
        double w = (pnt[z + j] - r2[i]).len();
        if (w < dis) dis = w, pv = z + j;
      }
      if (z - j >= 0 && pnt[z - j].a >= r2[i].a - dis) {
        fd = 1;
        double w = (pnt[z - j] - r2[i]).len();
        if (w < dis) dis = w, pv = z - j;
      }
      if (!fd) break;
    }
    mat[i] = pv;
    dd[i] = dis;
  }
  for (int i = 0; i < n2; i++) perm[i] = i, vis2[i] = 0;
  sort(perm, perm + n2, [&](int a, int b) { return dd[a] < dd[b]; });
  int cur = 0;
  ret = 0;
  for (int i = 0; i < n2; i++) {
    int u = perm[i], v = rk[mat[u]];
    if (vis1[v]) continue;
    pr[cur] = make_pair(v, u);
    ret += dd[u];
    vis2[u] = 1;
    vis1[v] = 1;
    cur++;
    if (cur >= n) break;
  }
  if (cur < n) {
    set<int> cand;
    for (int i = 0; i < n1; i++)
      if (!vis1[i]) cand.insert(i);
    for (int i = 0; i < n2; i++)
      if (!vis2[i]) {
        pr[cur++] = make_pair(*cand.begin(), i);
        cand.erase(cand.begin());
        if (cur >= n) break;
      }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &n1);
  for (int i = 0; i < n1; i++) scanf("%lf%lf", &q1[i].a, &q1[i].b);
  scanf("%d", &n2);
  for (int i = 0; i < n2; i++) scanf("%lf%lf", &q2[i].a, &q2[i].b);
  gao(q1, r1, n1);
  gao(q2, r2, n2);
  for (int it = 0; it < 4; it++) {
    match(r1, r2, n1, n2, n, pr[it], ret[it]);
    cd rot(0, 1);
    for (int i = 0; i < n2; i++) r2[i] = r2[i] * rot;
  }
  int z = min_element(ret, ret + 4) - ret;
  for (int i = 0; i < n; i++)
    printf("%d %d\n", pr[z][i].first + 1, pr[z][i].second + 1);
}
