This page is still under construction.

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

Symmetry

Interview

Time limit1sMemory limit128 MB

Summary
Decide whether the given dots mirror exactly across some vertical line, printing YES or NO for each test case.
Level

Medium5 of 10

Topics
Hash map, Geometry, Sorting
Solved
No attempts yet

Problem

The figure on the left is left-right symmetric: you can fold the sheet of paper along a vertical line (drawn as a dashed line) so that the two halves match exactly. The figure on the right is not left-right symmetric, because no such vertical line exists.

Write a program that decides whether a figure drawn as a set of dots is left-right symmetric. All dots are distinct.

Input

The first line contains the number of test cases TT.

Each test case begins with a line containing an integer NN (1≤N≤10001 \le N \le 1000), the number of dots in the figure. Each of the next NN lines contains two integers, the xx-coordinate and the yy-coordinate of a dot. Both coordinates are integers between −10000-10000 and 1000010000, inclusive.

Output

For each test case, print a single line: YES if the figure is left-right symmetric, or NO otherwise.

Examples3

  1. Example 1

    Input
    3
    5
    -2 5
    0 0
    6 5
    4 0
    2 3
    4
    2 3
    0 4
    4 0
    0 0
    4
    5 14
    6 10
    5 10
    6 14
    
    Expected output
    YES
    NO
    YES
    
  2. Example 2

    Input
    1
    1
    0 0
    
    Expected output
    YES
    
  3. Example 3

    Input
    1
    2
    -3 7
    3 7
    
    Expected output
    YES