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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
default_random_engine re;
const int MAXN = 50000;
const int MAXNN = (3 * MAXN + 1) / 2;
const double MPI = acos(-1.0);
struct P {
  double x, y;
  int idx;
  P() {}
  P(double x, double y) : x(x), y(y) {}
};
bool operator<(const P &a, const P &b) {
  if (fabs(a.x - b.x) > 1e-9) return a.x < b.x;
  if (fabs(a.y - b.y) > 1e-9) return a.y < b.y;
  return a.idx < b.idx;
}
P operator-(const P &a, const P &b) { return P(a.x - b.x, a.y - b.y); }
P operator+(const P &a, const P &b) { return P(a.x + b.x, a.y + b.y); }
double operator^(const P &a, const P &b) { return a.x * b.y - a.y * b.x; }
double side(const P &a, const P &b, const P &c) { return (b - a) ^ (c - a); }
double len(const P &a) { return sqrt(a.x * a.x + a.y * a.y); }
int n;
int na, nb;
P a[MAXNN], b[MAXNN];
P ha[MAXNN + 1];
int nha;
P hb[MAXNN + 1];
int nhb;
P p[MAXNN];
void calchull(P *_p, int np, P *h, int &nh) {
  for (int i = (0); i < (np); ++i) p[i] = _p[i];
  sort(p, p + np);
  nh = 0;
  for (int i = (0); i < (np); ++i) {
    while (nh >= 2 && side(h[nh - 2], h[nh - 1], p[i]) <= 0) --nh;
    h[nh++] = p[i];
  }
  int was = nh;
  for (int i = np - 2; i >= 0; --i) {
    while (nh > was && side(h[nh - 2], h[nh - 1], p[i]) <= 0) --nh;
    h[nh++] = p[i];
  }
  --nh;
}
P rot(const P &p, double ang) {
  double angcos = cos(ang), angsin = sin(ang);
  P ret(p.x * angcos - p.y * angsin, p.x * angsin + p.y * angcos);
  ret.idx = p.idx;
  return ret;
}
P c[MAXNN];
P d[MAXNN];
pair<double, int> oa[MAXNN];
pair<double, int> ob[MAXNN];
bool used[MAXNN];
const int MAGIC = 100;
pair<double, pair<int, int> > ret[MAXNN];
int nret;
bool solve(const P &a1, const P &b1, const P &a2, const P &b2) {
  P da = a2 - a1, db = b2 - b1;
  double anga = atan2(da.y, da.x), angb = atan2(db.y, db.x), ang = angb - anga;
  P c1 = rot(a1, ang), c2 = rot(a2, ang);
  P t = b1 - c1;
  for (int i = (0); i < (na); ++i)
    c[i] = rot(a[i], ang) + t, c[i].idx = a[i].idx;
  uniform_real_distribution<double> aunif(0, 2 * acos(-1.0));
  double rang = aunif(re);
  for (int i = (0); i < (na); ++i) c[i] = rot(c[i], rang);
  for (int i = (0); i < (nb); ++i) d[i] = rot(b[i], rang);
  for (int i = (0); i < (na); ++i) oa[i] = make_pair(c[i].x + c[i].y, c[i].idx);
  sort(oa, oa + na);
  for (int i = (0); i < (nb); ++i) ob[i] = make_pair(d[i].x + d[i].y, d[i].idx);
  sort(ob, ob + nb);
  int at = 0;
  nret = 0;
  for (int i = (0); i < (nb); ++i) used[i] = false;
  for (int i = (0); i < (na); ++i) {
    while (at < nb && oa[i].first > ob[at].first) ++at;
    int best = -1;
    double bestval = 1e200;
    for (int j = (0); j < (MAGIC); ++j) {
      if (at + j < nb && !used[ob[at + j].second]) {
        double curval = len(c[oa[i].second] - d[ob[at + j].second]);
        if (curval < bestval) bestval = curval, best = ob[at + j].second;
      }
      if (at - j >= 0 && !used[ob[at - j].second]) {
        double curval = len(c[oa[i].second] - d[ob[at - j].second]);
        if (curval < bestval) bestval = curval, best = ob[at - j].second;
      }
    }
    if (bestval < 0.1) {
      ret[nret++] = make_pair(bestval, make_pair(oa[i].second, best));
      used[best] = true;
    }
  }
  if (nret < n) return false;
  sort(ret, ret + nret);
  for (int i = (0); i < (n); ++i)
    printf("%d %d\n", ret[i].second.first + 1, ret[i].second.second + 1);
  return true;
}
void run() {
  scanf("%d", &n);
  scanf("%d", &na);
  for (int i = (0); i < (na); ++i)
    scanf("%lf%lf", &a[i].x, &a[i].y), a[i].idx = i;
  scanf("%d", &nb);
  for (int i = (0); i < (nb); ++i)
    scanf("%lf%lf", &b[i].x, &b[i].y), b[i].idx = i;
  calchull(a, na, ha, nha);
  calchull(b, nb, hb, nhb);
  for (int a1 = (0); a1 < (nha); ++a1)
    for (int a2 = (a1 + 1); a2 < (nha); ++a2)
      for (int b1 = (0); b1 < (nhb); ++b1)
        for (int b2 = (b1 + 1); b2 < (nhb); ++b2) {
          double da = len(ha[a1] - ha[a2]), db = len(hb[b1] - hb[b2]);
          if (fabs(da) < 0.1 || fabs(db) < 0.1 || fabs(da - db) > 0.02)
            continue;
          if (solve(ha[a1], hb[b2], ha[a2], hb[b1])) return;
          if (solve(ha[a1], hb[b1], ha[a2], hb[b2])) return;
        }
  printf("not found\n");
}
int main() {
  run();
  return 0;
}