Game with coins
시간 제한12초메모리 제한1024 MB
던진 동전과 주사위가 무작위 결과를 내는 미로 게임에서 매 턴 두 도구를 골라 말을 도착칸에 보내면 됩니다.
문제
This problem is interactive.
Taja can easily win this game, but all of her friends couldn't. Now she offers you to play this game.
Game equipment consists of field (), the piece, two coins (COIN1, COIN2), two dices with cardinal directions (DICE1, DICE2), and a lot of one cell size blocks.
Before the beginning of the game the piece and some blocks are placed on the field. Then the player makes moves such kind. At first, the player chooses a coin and tosses it for determine an action. Then he chooses one of the dices and rolls it for determine direction . After that one of the four action happens:
The goal is to put the piece on the finish cell.
One query for this problem is one coin toss and one dice roll.
입력
First line of the standard input contains one integer number --- the size of the maze. Next lines contains characters "." (ASCII ) or <<\#>> (ASCII ), denoting empty cell and cell with block respectively.
Next line contains two integer numbers and --- row number and column number of the finish cell. The upper-left corner is , the bottom-right is . Finish cell and initial cell are empty.
Next groups describes each move:
- The first line of an group contains two integer numbers , --- row number and column number of the piece, or , if the peace reaches the finish cell.
- Next line contains action name shown on the coin.
- Next line contains direction name shown on the dice.
- If the current action is "
RAM", next two strings contains two integer numbers , and , , denotes then the piece collides a block with coordinates and moves that block to the cell .
The north direction corresponds to decreasing row number. The south to increasing row number. The west direction to decreasing column number. The east direction to increasing column number.
Each side of any coin or dice is shown with the same probability.
출력
The standard output should consist of pair of lines: coin name and dice name. Coin name is the string "COIN1" or "COIN2". Dice name is the string "DICE1" or "DICE2".
힌트
The initial state of the maze for the sample is

And the representation of the path is shown below:









