403123: GYM101020 G Cutie Pie
Memory Limit:64 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
G. Cutie Pietime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output
Consider a NxM small-letters grid. SVU asked you to check whether this grid is a Cutie Pie or not A grid is a cutie pie if you can find the word "pie" in any direction (vertical, horizontal, and radial). Your program should output "Cutie Pie!" if the grid contains the word "pie" or "Sorry Man" otherwise
InputThe first line contains T 1<=T<=10000 the number of test cases. The followed T lines represent the test cases, each one contains two integers 0 < N,M ≤ 20 then N lines each of them contains M English small-letter separated by space characters. There is a blank line between each two successive test cases.
OutputFor each test case output "Cutie Pie!" if the grid in the test case contains the word "pie" or "Sorry Man" otherwise.
ExamplesInput2Output
3 5
o p r d t
i i i i e
f f s e d
4 3
o p r
o k r
i i u
f f s
Cutie Pie!
Sorry Man