Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tags yet

No tag edit access

A3. Death Stars (hard)

time limit per test

7 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe 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 *N*_{1} (*N* ≤ *N*_{1} ≤ 1.5·*N*) – the number of stars in the first map. The next *N*_{1} lines specify the coordinates of the stars in the first map. The *i*-th line contains two space-separated floating-point numbers *x*_{i} and *y*_{i} 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 *N*_{2} (*N* ≤ *N*_{2} ≤ 1.5·*N*) – the number of stars in the second map. The next *N*_{2} 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 *i*_{1} and *i*_{2}. Each such line should indicate that the star numbered *i*_{1} in the first map corresponds to the star numbered *i*_{2} 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,
*N*_{1}and*N*_{2}, 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
*N*_{1}-*N*and*N*2 -*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.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/19/2018 13:47:00 (d1).

Desktop version, switch to mobile version.

User lists

Name |
---|