시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB44323172.093%

문제

Snowflakes can be symmetrical both vertically and horizontally. Snowflakes that aren’t symmetrical are useless. A snowflake is essentially a two dimensional array of features. A feature is a single digit between 0 and 9. Horizontal symmetry occurs if you flip the snowflake horizontally. It is still the same snowflake. Likewise, vertical symmetry is defined in the same way. A snowflake is “Beautiful” if its horizontally symmetrical, “Graceful” if its vertically symmetrical, and “Magnificent” if it is both. Otherwise it is “Useless”. For each snowflake, print what kind of snowflake it is.

입력

The first line of data contains n, the number of inputs. Each input starts with a single integer k, k ≤ 20, denoting the dimension of the square snowflake. Then k lines follow with each line containing a string of length k denoting the digits in the snowflake.

출력

For each input. print the type of snowflake.

예제 입력 1

3
3
123
321
143
2
11
11
3
121
232
343

예제 출력 1

Useless
Magnificent
Graceful