Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/kesmalar-kesishuvi

Intersection of two segments

Medium 1000 ms 128 MB 45%
Share

Two segments are given on the plane: the endpoints of the first are $A(x_{1}; y_{1})$ and $B(x_{2}; y_{2})$, the endpoints of the second are $C(x_{3}; y_{3})$ and $D(x_{4}; y_{4})$. If segments $AB$ and $CD$ have at least one common point (they intersect or touch), print HA, otherwise print YOQ.

Two segments on the coordinate plane and their common point

Input

One line with eight integers: $x_{1}$, $y_{1}$, $x_{2}$, $y_{2}$, $x_{3}$, $y_{3}$, $x_{4}$ and $y_{4}$.

Output

One line with the corresponding word: HA or YOQ.

Note

$-10^{9} \le x_{i}, y_{i} \le 10^{9}$
The endpoints of each segment do not coincide.

Examples

Input #1
0 0 4 4 0 4 4 0
Output #1
HA
Input #2
0 0 2 2 3 3 5 5
Output #2
YOQ

Sign in to submit a solution

Signing up is free and takes a minute.