#include <bits/stdc++.h>
using namespace std;
int n, n1, n2;
pair<double, double> p1[1234567], p2[1234567];
pair<double, pair<int, int> > ps[5050666];
int pn = 0;
inline double dis(pair<double, double> x) {
  return x.first * x.first + x.second * x.second;
}
inline double ang(pair<double, double> x) { return atan2l(x.second, x.first); }
inline pair<double, double> operator-(pair<double, double> a,
                                      pair<double, double> b) {
  return pair<double, double>(a.first - b.first, a.second - b.second);
}
inline pair<double, double> operator+(pair<double, double> a,
                                      pair<double, double> b) {
  return pair<double, double>(a.first + b.first, a.second + b.second);
}
inline double dis(pair<double, double> x, pair<double, double> y) {
  return dis(x - y);
}
double co, si;
inline pair<double, double> rot(pair<double, double> g) {
  return pair<double, double>(g.first * co - g.second * si,
                              g.first * si + g.second * co);
}
pair<pair<double, double>, int> q1[1234567], qt[1234567];
bool vis[1234567];
void chk(pair<double, double> a1, pair<double, double> a2,
         pair<double, double> b1, pair<double, double> b2) {
  cerr << "=";
  double x1 = ang(a2 - a1), x2 = ang(b2 - b1);
  co = cosl(x2 - x1);
  si = sinl(x2 - x1);
  int tt = 0;
  for (int i = 1; i <= n1 && i <= 3000; ++i)
    qt[++tt].first = rot(p1[i] - a1) + b1;
  sort(qt + 1, qt + tt + 1);
  int sb = 0;
  for (int i = 1; i <= n2 && i <= 3000; ++i) {
    int o = lower_bound(qt + 1, qt + tt + 1, make_pair(p2[i], 0)) - qt;
    bool s = 0;
    for (int j = max(o - 10, 1); j <= min(o + 10, n1); ++j)
      if (dis(qt[j].first, p2[i]) < 1) {
        s = 1;
        break;
      }
    sb += s;
  }
  if (sb < 5) return;
  for (int i = 1; i <= n1; ++i)
    q1[i].first = rot(p1[i] - a1) + b1, q1[i].second = i, vis[i] = 0;
  sort(q1 + 1, q1 + n1 + 1);
  vector<pair<int, int> > rs;
  int fail = 0;
  for (int i = 1; i <= n2; ++i) {
    int o = lower_bound(q1 + 1, q1 + n1 + 1, make_pair(p2[i], 0)) - q1;
    bool s = 0;
    for (int j = max(o - 10, 1); j <= min(o + 10, n1); ++j) {
      if (dis(q1[j].first, p2[i]) < 1 && !vis[q1[j].second]) {
        rs.push_back(pair<int, int>(q1[j].second, i));
        fail = 0;
        s = 1;
        vis[q1[j].second] = 1;
        break;
      }
    }
    if (!s) ++fail;
    if (fail > 100) return;
  }
  random_shuffle(rs.begin(), rs.end());
  if (rs.size() >= n * 0.95) {
    if (rs.size() > n) rs.resize(n);
    for (int _ = 0; _ < rs.size(); ++_)
      printf("%d %d\n", rs[_].first, rs[_].second);
    for (int _ = rs.size(); _ < n; ++_) printf("1 1\n");
    exit(0);
  }
}
pair<double, double> md;
double gg[1234567];
bool cmp(int a, int b) { return gg[a] < gg[b]; }
inline bool myc(const pair<double, pair<int, int> >& a,
                const pair<double, pair<int, int> >& b) {
  return a.first < b.first;
}
int main() {
  cin >> n >> n1;
  for (int i = 1; i <= n1; ++i) cin >> p1[i].first >> p1[i].second;
  cin >> n2;
  for (int i = 1; i <= n2; ++i) cin >> p2[i].first >> p2[i].second;
  for (int i = 1; i <= n1 && pn < 4000000; ++i) {
    md = p1[i];
    vector<int> rs;
    for (int j = 1; j <= n1; ++j)
      if (j != i) rs.push_back(j), gg[j] = ang(p1[j] - md);
    sort(rs.begin(), rs.end(), cmp);
    for (unsigned _ = 0; _ < rs.size(); ++_) {
      int x = rs[_], y = rs[(_ + 1) % rs.size()];
      ps[++pn] = make_pair(dis(p1[x], p1[y]), pair<int, int>(x, y));
    }
  }
  while (pn < 5000000) {
    int x = rand() % n1 + 1, y = rand() % n1 + 1;
    if (x != y) ps[++pn] = make_pair(dis(p1[x], p1[y]), pair<int, int>(x, y));
  }
  sort(ps + 1, ps + 1 + pn, myc);
  for (int w = 1; w <= n2; ++w) {
    cerr << "=====\n";
    md = p2[w];
    vector<int> rs;
    for (int j = 1; j <= n2; ++j)
      if (j != w) rs.push_back(j), gg[j] = ang(p2[j] - md);
    sort(rs.begin(), rs.end(), cmp);
    int uu = 0;
    int p = rand() % rs.size();
    for (unsigned _ = 0; _ < rs.size(); ++_) {
      int i = rs[(_ + p) % rs.size()], j = rs[(_ + 1 + p) % rs.size()];
      double dx = dis(p2[i], p2[j]);
      int s = lower_bound(ps + 1, ps + 1 + pn,
                          make_pair(dx, pair<int, int>(0, 0))) -
              ps;
      for (int k = max(s - 5, 1); k <= min(s + 5, pn); ++k)
        if (fabs(dx - ps[k].first) < 0.1) {
          chk(p1[ps[k].second.first], p1[ps[k].second.second], p2[i], p2[j]);
          chk(p1[ps[k].second.first], p1[ps[k].second.second], p2[j], p2[i]);
          ++uu;
        }
      if (uu > 30) break;
    }
    int i = rand() % n2 + 1, j = rand() % n2 + 1;
    if (i == j) continue;
    double dx = dis(p2[i], p2[j]);
    int s =
        lower_bound(ps + 1, ps + 1 + pn, make_pair(dx, pair<int, int>(0, 0))) -
        ps;
    for (int k = max(s - 10, 1); k <= min(s + 10, pn); ++k)
      if (fabs(dx - ps[k].first) < 0.01) {
        chk(p1[ps[k].second.first], p1[ps[k].second.second], p2[i], p2[j]);
        chk(p1[ps[k].second.first], p1[ps[k].second.second], p2[j], p2[i]);
      }
  }
  throw "GG";
}
