题目描述
Problem Description
Porter has completed his MV on shallow water, but he quickly realized something was wrong: his microphone got wet.
The critical electronic components inside Porter's microphone can be considered as a 2D grid of size $n \times m$. We represent the internal state of the microphone with a character map of size $n \times m$, which includes three different characters:
.: Represents an empty spacex: Represents a critical electronic componento: Represents a water droplet
Water droplets will flow along the direction of gravity until they exit the boundary or reach an electronic component. When a water droplet reaches any electronic component, Porter's microphone will break. In a hurry, Porter turned the microphone, changing the direction of gravity inside. The direction of gravity is represented by one of four characters: ^v<>, corresponding to up, down, left, and right respectively.
Porter wants to know if his microphone will break under this gravity direction.
Input Format
The first line contains two positive integers and a character, representing $n$, $m$, and the direction of gravity respectively.
The next $n$ lines, each containing $m$ characters, represent the state of each point.
Output Format
Output a single line with a string. GG means Porter's microphone will break, and OK means it will not.
Sample Input and Output
Sample Input #1
3 3 v
.o.
...
xxx
Sample Output #1
GG
Sample Input #2
3 3 >
...
o.x
...
Sample Output #2
GG
Sample Input #3
3 3 ^
.o.
...
xxx
Sample Output #3
OK
Notes
Sample Explanation
Sample 1: The water droplet at the first row and second column flows down to the electronic component at the last row and second column, thus breaking the microphone.
Sample 2: The water droplet at the second row and first column flows right to the electronic component at the second row and last column, thus breaking the microphone.
Sample 3: The water droplet at the first row and second column flows directly up and out of the microphone, so Porter's microphone will not break.
Data Range
For all data, it is guaranteed that $1 \leq n, m \leq 100$, and the input data is valid.
Subtask 1 (10 pts): There are no x (electronic components) in the microphone.
Subtask 2 (10 pts): There are no o (water droplets) in the microphone.
Subtask 3 (30 pts): The gravity direction is always v (down).
Subtask 4 (50 pts): No special restrictions.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分