eolymp
bolt
Try our new interface for solving problems
Problems

Points symmetry

Points symmetry

\textit{\textbf{n}} different poins \textbf{P_1}, \textbf{P_2}, …, \textbf{P}\textit{\textbf{_n}} are given on the plane with coordinates (\textit{\textbf{x_i}}, \textit{\textbf{y_i}}), \textit{\textbf{i}} = \textbf{1}, …, \textit{\textbf{n}}. The transformation \textbf{S} works as follows: for each point \textbf{X}_0 of the plane we build the point \textbf{X_1}, symmetrical to it with respect to \textbf{P_1}, then we build the point \textbf{X_2}, symmetrical to \textbf{X}_\{1 \}with respect to \textbf{P_2} and so on until we bulid the point \textbf{X}\textit{\textbf{_n}} symmetrical to \textbf{X}\textit{\textbf{_n}}_\{-1 \}with respect to \textbf{P}\textit{\textbf{_n}}. If this transformation \textbf{S} has only one point that does not change its coordinates (fixed point), print its coordinates. If there exist more than one fixed point, print \textbf{0}. If the fixed point does not exist, print \textbf{-1}. \InputFile The first line contains the number of points \textit{\textbf{n}}. Each of the next \textit{\textbf{n}} lines contain the integer point coorinates (\textit{\textbf{x_i}}, \textit{\textbf{y_i}}), \textit{\textbf{i}} = \textbf{1}, …, \textit{\textbf{n}}. The number of points varies from \textbf{1} to \textbf{1000} inclusive, \textbf{x} and \textbf{y} are integers from \textbf{0} to \textbf{1000} inclusive. \OutputFile Print the coordinates of the fixed point (\textit{\textbf{x}}, \textit{\textbf{y}}) if it is unique. If there exist more than one fixed point, print \textbf{0}. If the fixed point does not exist, print \textbf{-1}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
0 0
0 1
1 0
Output example #1
1 -1
Author Mikhail Medvedev