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>
const bool DEBUG = false;
const int N_BASE = 50000;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using D = double;
using P = complex<D>;
ll rand_int(ll l, ll r) {
  using Dist = uniform_int_distribution<ll>;
  static random_device rd;
  static mt19937 gen(rd());
  return Dist(l, r)(gen);
}
D rand_D(D l, D r) {
  using Dist = uniform_real_distribution<D>;
  static random_device rd;
  static mt19937 gen(rd());
  return Dist(l, r)(gen);
}
const D PI = acos(D(-1)), EPS = 1e-10;
int sgn(D a) {
  if (abs(a) <= EPS) return 0;
  return (a < 0) ? -1 : 1;
}
bool near(P a, P b) { return !sgn(abs(a - b)); }
D mabs(P p) { return abs(p.real()) + abs(p.imag()); }
bool lessP(P l, P r) {
  if (sgn(r.real() - l.real())) return l.real() < r.real();
  if (sgn(r.imag() - l.imag())) return l.imag() < r.imag();
  return false;
}
D cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
D dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }
int N, N1, N2;
V<P> p1, p2;
using Pi = pair<int, int>;
using K = pair<Pi, int>;
V<K> mp_p1, mp_p2;
Pi roundp(P p) {
  int x = int(round(p.real()));
  int y = int(round(p.imag()));
  return Pi(x, y);
}
V<int> ans1, ans2;
void shuff(V<P> &v, V<int> &ans) {
  assert(DEBUG);
  D dx = rand_D(-10000, 10000);
  D dy = rand_D(-10000, 10000);
  P d = P(dx, dy);
  D th = rand_D(0, 2 * PI);
  P ar = polar<D>(1.0, th);
  for (auto &p : v) {
    p = (p + d) * ar;
    D x = round(p.real() * 100) / 100;
    D y = round(p.imag() * 100) / 100;
    p = P(x, y);
  }
  ans = V<int>(v.size());
  iota(begin(ans), end(ans), 0);
  V<P> v2(v.size());
  for (int i = 0; i < int(v.size()); i++) {
    v2[ans[i]] = v[i];
  }
  v = v2;
}
V<int> answer(V<Pi> v) {
  if (DEBUG) {
    set<Pi> st;
    assert(ans1.size() == N1);
    assert(ans2.size() == N2);
    for (int i = 0; i < N; i++) {
      st.insert(Pi(ans1[i], ans2[i]));
    }
    int ans = 0;
    for (auto pi : v) {
      if (st.count(pi)) {
        ans++;
        st.erase(pi);
      }
    }
    cout << "YOUR ANSWER: " << ans << " / " << N << endl;
  } else {
    while (v.size() < N) v.push_back(Pi(0, 0));
    for (auto p : v) {
      cout << p.first + 1 << " " << p.second + 1 << endl;
    }
  }
  exit(0);
}
void make() {
  if (DEBUG) {
    N1 = N + rand_int(0, N / 2);
    N2 = N + rand_int(0, N / 2);
    p1 = V<P>(N1);
    p2 = V<P>(N2);
    for (int i = 0; i < N; i++) {
      D x = rand_D(-10000, 10000);
      D y = rand_D(-10000, 10000);
      p1[i] = p2[i] = P(x, y);
    }
    for (int i = N; i < N1; i++) {
      D x = rand_D(-10000, 10000);
      D y = rand_D(-10000, 10000);
      p1[i] = P(x, y);
    }
    for (int i = N; i < N2; i++) {
      D x = rand_D(-10000, 10000);
      D y = rand_D(-10000, 10000);
      p2[i] = P(x, y);
    }
    shuff(p1, ans1);
    shuff(p2, ans2);
  } else {
    cin >> N;
    cin >> N1;
    p1 = V<P>(N1);
    for (int i = 0; i < N1; i++) {
      D x, y;
      cin >> x >> y;
      p1[i] = P(x, y);
    }
    cin >> N2;
    p2 = V<P>(N2);
    for (int i = 0; i < N2; i++) {
      D x, y;
      cin >> x >> y;
      p2[i] = P(x, y);
    }
  }
  for (int i = 0; i < N1; i++) {
    mp_p1.push_back(K(roundp(p1[i]), i));
  }
  for (int i = 0; i < N2; i++) {
    mp_p2.push_back(K(roundp(p2[i]), i));
  }
  sort(begin(mp_p1), end(mp_p1));
  sort(begin(mp_p2), end(mp_p2));
}
void check(int i1, int j1, int i2, int j2) {
  P di1 = -p1[i1], di2 = p2[i2];
  P base1 = polar<D>(1.0, -arg(p1[j1] - p1[i1]));
  P base2 = polar<D>(1.0, arg(p2[j2] - p2[i2]));
  V<Pi> res;
  for (int i = 0; i < N1; i++) {
    P q1 = p1[i];
    q1 += di1;
    q1 *= base1;
    q1 *= base2;
    q1 += di2;
    Pi key = roundp(q1);
    auto it = lower_bound(begin(mp_p2), end(mp_p2), K(key, -1));
    if (it != mp_p2.end() && it->first == key) {
      res.push_back(Pi(i, it->second));
    }
    if (i == N1 / 40 && res.size() <= 10) break;
  }
  if (res.size() > N * 9 / 10) answer(res);
}
D norm(const P &p) { return p.real() * p.real() + p.imag() * p.imag(); }
void solve() {
  map<D, Pi> mp;
  constexpr int B = 13000;
  for (int ph = 0; ph < B; ph++) {
    int i = rand_int(0, N1 - 1);
    D mi = 1e100;
    int mj = -1;
    for (int j = 0; j < N1; j++) {
      if (i == j) continue;
      D di = norm(p1[i] - p1[j]);
      if (di < mi) {
        mi = di;
        mj = j;
      }
    }
    mp[sqrt(mi)] = Pi(i, mj);
  }
  for (int ph = 0; ph < B; ph++) {
    int i = rand_int(0, N2 - 1);
    D mi = 1e100;
    int mj = -1;
    for (int j = 0; j < N2; j++) {
      if (i == j) continue;
      D di = norm(p2[i] - p2[j]);
      if (di < mi) {
        mi = di;
        mj = j;
      }
    }
    mi = sqrt(mi);
    auto it = mp.lower_bound(mi);
    if (it == mp.end()) continue;
    auto buf = *it;
    if (abs(mi - buf.first) < 1e-2) {
      cerr << "FIND? " << mi << " " << buf.first << endl;
      check(buf.second.first, buf.second.second, i, mj);
      check(buf.second.first, buf.second.second, mj, i);
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  N = N_BASE;
  make();
  solve();
  return 0;
}