Description
Push Box is a classic game. , the gray lattice means that the area cannot be passed, the blue box is the case, the black circle represents the player, and the lattice containing the dots represents the target point.
Specify the following rules:
1, a game will only have a box, a player and a target point.
2. Control the movement of the player via the arrow keys.
3, the figure of the gray lattice represents the wall, the player and the box can not pass.
4, pushed to the wall of the box, you can no longer push the box away from the wall, because the player can not reach the box on the side of the wall to push the box. This means that the box can only be moved in a "pushed" manner, not in a "pulled" manner. However, if the player pushes the box to the wall and there are no obstructions on either side of the vertical wall, the player can move the box in these two different directions. If the box enters the corner, there is no way to push the box again.
5, the player can not walk out of the scene. The player pushes the box to the edge of the scene, and if you continue clicking the arrow keys that move the player and the box toward the wall, the box and people will remain motionless. If there is a wall in the direction of the player, it cannot go forward. But these clicks are considered a reasonable input.
6, once the box reaches the target point, it can no longer move. However, the player can still move freely within the scene. If you continue to push the box, the player will remain in place with the box.
Now, given a click of a directional key, determine if this scheme will eventually stop the box at the target point. For convenience, we represent a blank lattice with 0, 4 means that we cannot pass the area, 1 for the player, 3 for the box, and 2 for the target.
input
The first row of data contains three integers, n,m,s. where n (0 < n <= 100) represents the width of the lattice, M (0 < M <= 100) represents the height of the lattice, s (0 < s <= 200) represent the number of test points.
The next M-line, each row will have n characters, describing the current face.
The next S-line, each line represents a test point. Each line starts with an integer t (0 < T <= 10000), followed by a space and a T-character. This T-character consists only of the four letters of the D,U,L,R, which represent the arrow keys that strike down, up, left, and right.
Output
For each test point, the final box is output at the target point. If yes, the output is yes, and if not, the output is no.