410201: GYM103973 K The Grandstand
Description
On the 70th anniversary of HUST (Hualishu University of Science and Technology), the grandstand in the playground near QinYuan is renewed!
Walk Alone loves the new grandstand. He finds that the new grandstand is a matrix of $$$n\times m$$$ seats with $$$n$$$ rows and $$$m$$$ columns, and each seat is colored either blue, red or white. The red seats in the grandstand form the shape of 'HUST' together.
What is more, Walk Alone finds that the shape of the four letters should satisfy the following rules:
- 'H'. There exists positive integers $$$x_0,y_0,x,y,z,d$$$, such that $$$$$$ R=[0,0,x+y+d,d]\cup [0,z+d,x+y+d,z+2d]\cup [x,d,x+d,z+d] $$$$$$ where $$$[x_1,y_1,x_2,y_2]=\{(x+x_0,y+y_0)\mid x_1\le x<x_2,y_1\le y<y_2\}$$$, and $$$R$$$ denotes the set of coordinates of all red seats.
- 'U'. There exists positive integers $$$x_0,y_0,x,y,d$$$, such that $$$$$$ R=[0,0,x+d,y+2d]- [0,d,x,y+d] $$$$$$
- 'S'. There exists positive integers $$$x_0,y_0,x,y,z,d$$$, such that $$$$$$ R=[0,0,x+y+3d,z+d]- [d,d,x+d,z+d]- [x+2d,0,x+y+2d,z] $$$$$$
- 'T'. There exists positive integers $$$x_0,y_0,x,y,z,d$$$, such that $$$$$$ R=[0,0,d,x+y+d]\cup [d,x,z+d,x+d] $$$$$$
For better understanding, it is recommended to see the illustration below ($$$x,y,z$$$ and $$$d$$$ are arbitrary positive integers):
Now Walk Alone gives you a part of the grandstand, in which some seats are colored red. You need recognize whether it belongs to one of 'H', 'U', 'S', 'T', or Walk Alone is cheating (it does not belong to any of the four letters).
InputThe input contains multiple test cases.
The first line of the input contains an integer $$$T\ (1\le T\le 10)$$$, the number of test cases.
For each test case, the first line contains two integers $$$n$$$ and $$$m\ (1\le n,m\le 3000)$$$, indicating the size of grandstand.
Each of the next $$$n$$$ lines is a string of length $$$m$$$ consisting only of '.' and 'x'. The $$$j$$$-th character in the $$$i$$$-th line is 'x' if and only if the seat located at the $$$j$$$-th column and the $$$i$$$-th row is red.
OutputFor each test case, output one of 'H', 'U', 'S' or 'T' as the answer, or 'OOPS!' (without quotes) if none of them are correct.
ExampleInput4 6 5 .xxx. .x... .xxx. ...x. ...x. .xxx. 5 5 xx.xx xx.xx xxxxx xxxxx xx.xx 5 5 xx..x xx..x xxxxx xxxxx xx..x 2 3 xxx ..xOutput
S H OOPS! OOPS!