eolymp
bolt
Try our new interface for solving problems
Problems

Scrooge`s Tower

Scrooge`s Tower

Scrooge McDuck owns a circular island of radius \textbf{R} centered at the origin. He wants to build a square tower there to keep all his wealth. The wealth is quite huge, so the square of the foundation should be inscribed in the circle of the island. After reading a lot of popular magazines, Mrs. Beakley claimed that according to feng shui, the entrance to the tower should be situated at the point (\textbf{x_1}, \textbf{y_1}), and the exit should be at the point (\textbf{x_2}, \textbf{y_2}). Of course, entrance and exit points should lie on the border of tower's foundation. Scrooge told you all these numbers and wants to know if it is possible to satisfy Mrs. Beakley's requirements. \InputFile The first line contains an integer \textbf{T} --- the number of test cases (\textbf{1} ≤ \textbf{T} ≤ \textbf{1000}). Each of the next \textbf{T} lines contains five integers separated by spaces: \textbf{R}, \textbf{x_1}, \textbf{y_1}, \textbf{x_2}, \textbf{y_2}. \textbf{1} ≤ \textbf{R} ≤ \textbf{10000}. Points \textbf{(x_1, y_1)} and \textbf{(x_2, y_2)} are situated inside the circle. \OutputFile For each of the \textbf{T} cases output "\textbf{YES}" if the tower can be built, and "\textbf{NO}" otherwise.
Time limit 0.5 seconds
Memory limit 64 MiB
Input example #1
3
2 1 1 1 -1
2 1 1 0 0
1 1 0 -1 0
Output example #1
YES
NO
YES
Source Ural SU Contest. Petrozavodsk Summer Session, August 2008