Snowflakes often appear to have six-fold radial symmetry due to the hexagonal crystalline structure of ice. C.C., amazed by this fact, collects the most interesting snowflakes she can find across UT. Examining them with a microscope, she finds certain rare ones break this six-fold symmetry. Help her identify these snowfakes!
C.C. maps the snowflake's vertices onto a unique coordinate grid, with the snowflake centered at the origin $$$(0,0)$$$. Rather than the traditional Cartesian grid, she uses two unit vectors separated by an angle of $$$60^\circ$$$:
A point recorded as $$$(u, v)$$$ represents the position $$$u \cdot \mathbf{e_1} + v \cdot \mathbf{e_2}$$$. This grid lends itself to the nature of snowflakes—all points can be represented with integer coordinates!
A snowflake is considered perfect if rotating the set of points by $$$60^\circ$$$ around the origin results in the exact same set of points. Given $$$1 \le N \le 10^5$$$ points, determine if C.C. has found a perfect snowflake.
The first line of input contains an integer $$$N$$$ ($$$1 \le N \le 10^5$$$) — the number of vertices in the snowflake.
Each of the next $$$N$$$ lines contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$-10^9 \le u_i, v_i \le 10^9$$$) — the coordinates of the $$$i$$$-th vertex in C.C.'s grid system. It is guaranteed that all $$$N$$$ points are distinct.
Print a single line containing the string "YES" if the snowflake is perfect (i.e., it has 6-fold rotational symmetry about the origin), or "NO" otherwise.
70 02 1-1 3-3 2-2 -11 -23 -2
NO
70 02 1-1 3-3 2-2 -11 -33 -2
YES
The purple points below describe the first test case's not perfect snowflake. The vectors $$$\mathbf{e_1}$$$ and $$$\mathbf{e_2}$$$ are shown in red and blue, respectively.