This page is still under construction.

Parts of this page are still being built. What you see may change.

Acrobat Reader

Time limit1sMemory limit128 MB

Summary
For each test case, decide whether two sets of N points match under rotation by a multiple of 90 degrees, translation, and positive uniform scaling, with reflections disallowed.
Level

Medium7 of 10

Topics
Geometry, Hash map, Sorting, Math
Solved
No attempts yet

Problem

At an airport, biometric data is used to confirm that travelers are who they claim to be. A circus troupe touring abroad next month expects trouble at border control: when its acrobats face the camera, there is no telling which way their face will be oriented. You may assume that every acrobat looks straight into the camera, but the recorded face may be rotated by a multiple of 90 degrees. As with any passenger, the picture may also be translated and uniformly scaled (by the same factor along both axes).

You are given several pairs of biometric scans; each pair consists of one scan taken from the passport and one recorded live. For every acrobat, decide whether the two scans match.

Two scans match when one can be turned into the other using a rotation of 0°0°, 90°90°, 180°180°, or 270°270°, a translation, and a positive uniform scaling. Reflections (mirror images) are not allowed.

Input

The first line contains a single integer: the number of test cases.

Each test case has the following format.

  • One line with an integer NN (1≤N≤100001 \le N \le 10000): the number of points in each of the acrobat's two scans.
  • NN lines, each with two integers xix_i and yiy_i (−10000≤xi,yi≤10000-10000 \le x_i, y_i \le 10000): a point of the first scan (from the passport).
  • NN lines, each with two integers xix_i and yiy_i (−10000≤xi,yi≤10000-10000 \le x_i, y_i \le 10000): a point of the second scan (recorded live).

The two integers on a line are separated by a single space. Within one scan no two points are identical, and the NN points are listed in arbitrary order.

Output

For each test case, print a single line: okay if the two scans match, or mismatch! if they do not.

Examples7

  1. Example 1

    Input
    2
    3
    -1 1
    0 -1
    1 0
    -1 0
    1 -2
    3 2
    3
    0 0
    2 1
    2 2
    0 0
    -2 1
    -2 2
    
    Expected output
    okay
    mismatch!
    
  2. Example 2

    Input
    2
    1
    7 7
    -4 9
    3
    0 0
    0 1
    1 0
    1 0
    0 0
    0 1
    
    Expected output
    okay
    okay
    
  3. Example 3

    Input
    4
    3
    0 0
    0 1
    1 0
    100 -50
    100 -49
    101 -50
    3
    0 0
    0 1
    1 0
    3 7
    2 7
    3 8
    3
    0 0
    0 1
    1 0
    -10 4
    -10 1
    -13 4
    3
    0 0
    0 1
    1 0
    7 5
    5 3
    5 5
    
    Expected output
    okay
    okay
    okay
    okay
    
  4. Example 4

    Input
    2
    4
    0 0
    1 0
    2 1
    3 3
    0 0
    -1 0
    -2 1
    -3 3
    4
    0 0
    1 0
    2 1
    3 3
    4 4
    4 2
    2 0
    -2 -2
    
    Expected output
    mismatch!
    mismatch!
    
  5. Example 5

    Input
    2
    3
    0 0
    0 1
    2 0
    0 0
    0 1
    1 0
    4
    0 0
    2 0
    2 2
    0 2
    0 0
    1 0
    1 3
    0 3
    
    Expected output
    mismatch!
    mismatch!
    
  6. Example 6

    Input
    1
    5
    0 0
    3 0
    0 3
    -3 0
    0 -3
    9 9
    9 15
    3 9
    9 3
    15 9
    
    Expected output
    okay
    
  7. Example 7

    Input
    5
    3
    0 0
    0 1
    1 0
    -3 -3
    -3 -8
    -8 -3
    4
    0 0
    1 0
    2 1
    3 3
    0 0
    -1 0
    -2 1
    -3 3
    1
    1 1
    9 9
    2
    0 0
    10 0
    2 2
    2 -38
    3
    0 0
    0 1
    2 0
    0 0
    0 2
    1 0
    
    Expected output
    okay
    mismatch!
    okay
    okay
    mismatch!