Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/oxshash-uchburchaklar

Similar triangles?

Medium 1000 ms 128 MB 47%
Share

Two triangles are given on the plane by the coordinates of their vertices; both have positive area. Are they similar, that is, can one of them be scaled up or down, rotated, shifted and, if necessary, mirrored so that it exactly coincides with the other? If so, print YES, otherwise print NO.

Two triangles: one is a scaled and rotated copy of the other, the corresponding sides are highlighted

Input

The first line contains six integers — the vertices of the first triangle: $x_{1}$ $y_{1}$ $x_{2}$ $y_{2}$ $x_{3}$ $y_{3}$.
The second line contains six integers in the same way — the vertices of the second triangle.

Output

YES or NO.

Note

all coordinates are from $-10^{5}$ to $10^{5}$

Examples

Input #1
0 0 4 0 0 3
1 1 1 9 7 1
Output #1
YES
Input #2
0 0 2 0 0 2
0 0 3 0 0 1
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.