Problem: The stardate is 2015, and Death Stars are bigger than ever! This time, two rebel spies have yet again given Heidi two maps with the possible locations of the Death Stars.

Heidi has now received two maps with possible locations of N Death Stars. She knows that each of the maps is possibly corrupted, and may contain some stars that are not Death Stars. Furthermore, each of the maps was created from a different point of view. Hence, stars that are shown in one of the maps are rotated and translated with respect to the other map. Now Heidi wants to find out which of the stars shown in both maps are actually Death Stars, and the correspondence between the Death Stars on the two maps. 

Input

The first line of the input contains an integer N (1000 ≤ N ≤ 50000) – the number of Death Stars. The second line of the input contains an integer N1 (N ≤ N1 ≤ 1.5·N) – the number of stars in the first map. The next N1 lines specify the coordinates of the stars in the first map. The i-th line contains two space-separated floating-point numbers xi and yi with two decimal digits of precision each, representing the coordinates of the i-th star in the first map.

The next line of the input contains an integer N2 (N ≤ N2 ≤ 1.5·N) – the number of stars in the second map. The next N2 lines contain locations of the stars in the second map, given in the same format as for the first map. 

Output

You should output exactly N lines, each containing a space-separated pair of integers i1 and i2. Each such line should indicate that the star numbered i1 in the first map corresponds to the star numbered i2 in the second map. Your answer will be considered correct if over 90% of the distinct pairs listed in your output are indeed correct.

Note

The tests are generated in the following way: 

  * The number of Death Stars N is pre-selected in some way. 
  * The numbers of stars on the first and on the second map, N1 and N2, are selected uniformly at random between 1.0 × N and 1.5 × N. 
  * N Death Stars are generated at random, with coordinates between  - 10000 and 10000. 
  * Additional N1 - N and N2 - N stars for the first and for the second map respectively are generated in the same way. 
  * A translation vector (dx, dy) is generated, with dx and dy selected uniformly at random between  - 10000 and 10000. Each point in the first map is translated by (dx, dy). 
  * A rotation angle θ is generated, with θ selected uniformly at random between 0 and 2π. Each point in the first map is rotated by an angle of θ around the origin. 
  * Translations and rotations for the second map are generated and applied in the same way. 
  * The order of points is randomly permuted for both maps. 
  * The test case is saved, with each point written with two decimal digits of precision. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int Imx = 2147483647;
const long long Lbig = 2e18;
const int mod = 1e9 + 7;
const double eps = 1;
const double pi = acos(-1);
bool is0(double x) { return x > -eps && x < eps; }
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) {
    x = _x;
    y = _y;
  }
  point operator+(const point &t) const { return point(x + t.x, y + t.y); }
  point operator-(const point &t) const { return point(x - t.x, y - t.y); }
  point operator*(const point &t) const {
    return point(x * t.x - y * t.y, x * t.y + y * t.x);
  }
  point operator*(const double &t) const { return point(x * t, y * t); }
  point operator/(const double &t) const { return point(x / t, y / t); }
  point operator-() const { return point(-x, -y); }
  double len() const { return sqrt(x * x + y * y); }
  double sqrl() const { return x * x + y * y; }
  point operator/(const point &t) const {
    return point(x * t.x + y * t.y, -x * t.y + y * t.x) / t.len() / t.len();
  }
  double det(const point &t) const { return x * t.y - y * t.x; }
  double dot(const point &t) const { return x * t.x + y * t.y; }
  double len2() const { return x * x + y * y; }
  point unit() const { return (*this) / len(); }
  bool operator<(const point &t) const {
    return is0(x - t.x) ? (is0(y - t.y) ? 0 : y < t.y) : x < t.x;
  }
  bool operator==(const point &t) const { return is0(x - t.x) && is0(y - t.y); }
  void out() { cerr << x << "," << y << endl; }
  double rad() const { return atan2(y, x); }
  point conj() const { return point(x, -y); }
};
double area(double x, double y, double z) {
  double p = (x + y + z) / 2;
  return sqrt(p * (p - x) * (p - y) * (p - z));
}
bool parallel(const point &px, const point &py, const point &qx,
              const point &qy) {
  return is0((px - py).det(qx - qy));
}
point intersection(const point &px, const point &py, const point &qx,
                   const point &qy) {
  double t = -(px - qx).det(qy - qx) / (py - px).det(qy - qx);
  return px + (py - px) * t;
}
point intersection(const pair<point, point> &p, const pair<point, point> &q) {
  return intersection(p.first, p.second, q.first, q.second);
}
bool segcross_in(const point &px, const point &py, const point &qx,
                 const point &qy) {
  if (parallel(px, py, qx, qy)) return false;
  point p = intersection(px, py, qx, qy);
  return (px - p).dot(py - p) < eps && (qx - p).dot(qy - p) < eps;
}
bool segcross_ex(const point &px, const point &py, const point &qx,
                 const point &qy) {
  if (parallel(px, py, qx, qy)) return false;
  point p = intersection(px, py, qx, qy);
  return (px - p).dot(py - p) < -eps && (qx - p).dot(qy - p) < -eps;
}
double pointtoseg(point p, point pl, point pr) {
  double mndis = min((p - pl).len(), (p - pr).len());
  point q = intersection(pl, pr, p, p + (pr - pl) * point(0, 1));
  if ((pl - q).dot(pr - q) < 0) mndis = min(mndis, (p - q).len());
  return mndis;
}
double pointtoline(point p, point pl, point pr) {
  point q = intersection(pl, pr, p, p + (pr - pl) * point(0, 1));
  return (p - q).len();
}
int n, n1, n2;
point A[100011], B[100011];
map<point, int> mp;
long long rnd() { return 1ll * rand() * RAND_MAX + rand(); }
bool fA[100111], fB[100111];
pair<double, int> da[100111];
pair<double, int> db[100111];
void check(int xa, int xb, int ya, int yb) {
  point r = (A[xb] - A[xa]) / (B[yb] - B[ya]);
  point c = A[xa] - B[ya] * r;
  int cnt1 = 0, cnt0 = 0;
  for (int i = 1; i <= n2; i++) {
    point p = r * B[i] + c;
    if (mp.find(p) != mp.end())
      cnt1++;
    else
      cnt0++;
    if (cnt1 + cnt0 >= 20 && 1.0 * cnt1 / (cnt0 + cnt1) < 0.1) {
      break;
    }
  }
  if (cnt1 > 0.9 * n) {
    vector<pair<int, int> > v;
    for (int j = 1; j <= n2; j++) {
      point cur = B[j] * r + c;
      if (mp.find(cur) != mp.end()) {
        int nxt = mp[B[j] * r + c];
        if (v.size() < n) {
          v.push_back(make_pair(nxt, j));
          fA[nxt] = 1;
          fB[j] = 1;
        }
      }
    }
    int itA = 1, itB = 1;
    while (v.size() < n) {
      while (fA[itA]) itA++;
      while (fB[itB]) itB++;
      v.push_back(make_pair(itA, itB));
      fA[itA] = 1;
      fB[itB] = 1;
    }
    for (int i = 0; i < n; i++) {
      printf("%d %d\n", v[i].first, v[i].second);
    }
    exit(0);
  }
}
void solve(int x, int y) {
  for (int i = 1; i <= n1; i++) {
    da[i] = make_pair((A[x] - A[i]).sqrl(), i);
  }
  sort(da + 1, da + n1 + 1);
  for (int i = 1; i <= n2; i++) {
    db[i] = make_pair((B[i] - B[y]).sqrl(), i);
  }
  sort(db + 1, db + n2 + 1);
  int j = 2;
  for (int i = 2; i < n1; i++) {
    while (j < n2 && db[j].first + 1 < da[i].first) {
      j++;
    }
    for (int t = j; db[t].first < da[i].first + 5 && t < n2; t++) {
      check(x, da[i].second, y, db[t].second);
      check(x, da[i].second, db[t].second, y);
    }
  }
}
int main() {
  srand(20020626);
  scanf("%d", &n);
  scanf("%d", &n1);
  for (int i = 1; i <= n1; i++) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    A[i] = point(x, y);
    mp[A[i]] = i;
  }
  scanf("%d", &n2);
  for (int i = 1; i <= n2; i++) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    B[i] = point(x, y);
  }
  while (true) {
    int x = rnd() % n1 + 1;
    int y = rnd() % n2 + 1;
    solve(x, y);
  }
  return 0;
}