eolymp
bolt
Try our new interface for solving problems
Problems

Линейный чёрный ящик

Линейный чёрный ящик

There is a linear function of two arguments \textbf{f}(\textbf{x}, \textbf{y}) = \textbf{ax + by + c}, where the coefficients \textbf{a}, \textbf{b}, \textbf{c} are unknown. According to \textbf{N} values of \textbf{f}(\textbf{x_1}, \textbf{y_1}) = \textbf{d_1}, ..., \textbf{f}(\textbf{x_N}, \textbf{y_N}) = \textbf{d_N} is required to determine uniquely the function \textbf{f}(\textbf{u}, \textbf{v}) or indicate that it is impossible. Note that uniquely restore the function itself is not required. It is guaranteed that the function \textbf{f} exists. \InputFile The input file contains integers\textbf{N}\textit{ }\textbf{u} \textbf{v}, followed by \textbf{N} triples of integers\textbf{ x_i y_i d_i}. \OutputFile Output file must contain a unique integer \textbf{f}(\textbf{u}, \textbf{v}) any \textit{two} numbers \textbf{0} (zero) if the unambiguous identification impossible. \textbf{1} ≤ \textbf{N} ≤ \textbf{100}, \textbf{−10^6} ≤ \textbf{x_i},\textbf{ y_i},\textbf{ d_i} ≤ \textbf{10^6}, the coefficients \textbf{a},\textbf{ b},\textbf{ c} --- integer.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 5 6
5 6 500000 

Output example #1
500000