~/algor $ cat problems/qavslar-balansi
Balanced brackets
Medium
1000 ms
64 MB
45%
A string $s$ consisting only of the characters (, ), [, ], {, } is given. Are the brackets placed correctly? The brackets are placed correctly if every opening bracket is closed by a closing bracket of the matching type in the correct order. For example, ([]{}) is correct, and ([)] is not.
Input
One line with the string $s$.
Output
HA if the brackets are placed correctly, otherwise YOQ.
Note
$1 \le |s| \le 2 * 10^{5}$
$s$ consists only of the characters (, ), [, ], {, }
Examples
Input #1
([]{})
Output #1
HA
Input #2
([)]
Output #2
YOQ