Problem:
Problem L: The Tower

Your task is to write a program that reads some lines of command for the following game and simulates operations until the player reaches the game over. We call following 2-dimensional grid of m by n characters Tower. The objective of this game is to move blocks in the tower to climb to a goal block. In the following grid, the bottom line is the first row and the top one is the n-th row. The leftmost column is the first column and the rightmost one is the m-th column.

.................... (n=13 th row)
.....#.....G........
....##.....##.....##
...####...IIII...###
..####.....##.....##
...####B..####....##
....###....#33##..##
.....####...#33#3.##
.##CCCC#####2##.####
..#####..###.#...###
...###....###.....#1
....####..##.......#
S..###..#.####.....# (1st row)

Explanation of cell marks:

'#' : Normal block
Normal block.

'I' : Ice block
Block made of the ice. This has different features from the normal one.

'G' : Goal block
If the player climbs to this, game is over and clear.

'C' : Fixed block
The player can not move this directly.

'B' : Different dimensional block
If the player climbs to this, game is over and lose.

'.' : Space
Empty place.

'3' : Fragile block(3)
A fragile block of count 3.

'2' : Fragile block(2)
A fragile block of count 2.

'1' : Fragile block(1)
A fragile block of count 1. If the count is zero, this block will be broken and become a space.

'S' : Player
The player.

Explanation of relative positions:

123
4S5
678

In the following description, assume that left up is the position of 1, up(over S) is 2, right up is 3, left is 4, right is 5, left down is 6, down(under S) is 7, right down is 8 for S.

Movements of the player

The player must not go out of the tower. The outside of the tower is considered as space cells.

Move
The player can move everywhere in the current row as long as some of the following conditions are satisfied.

The player is in the first row and the target cell is a space.

There are blocks under the route connecting the current cell and the target cell (horizontal segment) and the target cell is a space. It is OK that some blocks in the horizontal segment. And the case that some of blocks under the segment are different dimensional ones, it is also OK.

Climb

If the player at the row below the n-th row (from 1st to n-1 th row) and there is a block in the right(left) and both of a cell over the player (up cell) and a right up(left up) cell are space, the player can move to the right up(left up) cell.

Get down

If the player at the row above the 1st row (from 2nd to n-th row), he can get down to right(left) down. If the direction for getting down is right(left) and if there is no blocks in the right down (left down) cell and the right (left) cell, the player can move to the right down (left down) cell.

Push

If there is a block or continuous blocks in the right or left of the player, he can push the blocks to the direction one cell. Here, blocks are "continuous" if there are two or more blocks and no space exist between them. However, if there is a fixed block in pushing blocks, the player can not push them. Pushed blocks will not stop the end of the row of the tower (1st and mth column). If the pushed blocks go out of the tower, this will be vanished.
In the result of pushing, a block moved over the ice block continues to move to the pushed direction as long as there is a space in the progress direction, there is an ice block under the block and the pushed block is not vanished.

If the pushed block is an ice block, this continues to move to the pushed direction as long as there is a block under the ice block, there is a space in the progress direction and the pushed ice block is not vanished. However, for an ice block in the first row, the below the block do not have to be a space. And here, if the player pushes continuous blocks, pushing movements begin from the most distant block to a nearest block. Here, the distance is manhattan distance at the gird.

Pull

If there is a block in the right(left) of the player and the left(right) cell is space, the player can pull the block. However, if the pulling block is fixed one, he can not pull this. If the player pulls block, the player will move one cell to the direction of pulling.

Automated operations after the player operation:

Automated operations occur in the following order. This repeats in this order as long as the cells of the tower are changed by this operations. After this operations, the player can do the next operation.

Countdown of fragile blocks

If the player over a fragile block moved to somewhere else, that fragile block's count will decrease by one. However, this count does not change if the player over the fragile block is moved to somewhere else by the automated operations.

Erasing blocks
A block over an different dimensional block will be vanished.

Falling of the player
If there is no block under the player, the player continues to fall as long as satisfying this condition or come to 1st row.

Falling of blocks
If there is no block under a block and left down and right down of a certain block, the block in the row over the 1st row (from 2nd to n-th row) continues to fall as long as satisfying this condition. Falling of blocks begins from lower blocks of the tower and then lefter blocks.

Conditions for game over:

After the movement of the player or the automated operations, the game is over when the one of next conditions is satisfied. These conditions are judged in the following order. Note that, the condition (E) should not be judged after the movement of the player.

(A) The player is over the goal block.

(B) The player is over the different dimensional block.

(C) The player and a block is in the same cell.

(D) The goal block is moved from its initial position.

(E) There is no next commands.

Finally, show some examples.

Documents of commands will be give in the description of Input.

Example table

Movement or
Automated operation

Before

After

Command

Move

.#S
###

S#.
###

MOVETO 1

Climb

...
3S#

S..
3.#

CLIMB LEFT

Get down

S..
3.#

...
2S#

GETDOWN RIGHT

Push

.#S#####..
###II.I.I.

.#S.####.#
###II.I.I.

PUSH RIGHT

Push

.#SI...
###.###

.#S....
###.###

PUSH RIGHT

Push

.#...S#
###.###

.....S.
###.###

PUSH RIGHT

Pull

..S#####..
###.#.#.#.

.S#.####..
###.#.#.#.

PULL LEFT

Falling of the player

.#S#
.#.#
.#.#
.#.#

.#.#
.#.#
.#.#
.#S#
-

Falling of blocks

.###.
#...#
#...#
#...#
.#.#

.#.#.
#...#
#...#
#.#.#
.#.#
-

Input

Input consists of multiple datasets.

A dataset is given in the following format.

n m
Dn,1 Dn,2 ... Dn,m
Dn-1,1 Dn-1,2 ... Dn-1,m
...
D1,1 D1,2 ... D1,m
T
Command1
Command2
...
CommandT

Here, m, n is the width and height of the tower. Di,j(1≤i≤n and 1≤j≤m) is a mark of the cell. The explanation of marks described above. Commandk(1≤k≤T) is the k-th player operation (movement). This is a string and one of following strings.

"MOVETO s" means move to s-th column cell in the same row.
"PUSH RIGHT" means push right block(s).
"PUSH LEFT" means push left block(s).
"PULL RIGHT" means pull the left block to right.
"PULL LEFT" means pull the right block to left.
"GETDOWN RIGHT" means get down to right down.
"GETDOWN LEFT" means get down to left down.
"CLIMB RIGHT" means climb to the right block.
"CLIMB LEFT" means climb to the left block.

Some of commands are invalid. You must ignore these commands. And after game is over, the command input may continue in case. In this case, you must also ignore following commands. m=n=0 shows the end of input.

Constraints

3≤m≤50

3≤n≤50

Characters 'S' and 'G' will appear exactly once in the tower description.

Output

Each dataset, output a string that represents the result of the game in the following format.

Result

Here, Result is a string and one of the following strings (quotes for clarity).

"Game Over : Cleared" (A)

"Game Over : Death by Hole" (B)

"Game Over : Death by Block" (C)

"Game Over : Death by Walking Goal" (D)

"Game Over : Gave Up" (E)

Sample Input

8 8
........
........
....###.
...#.#.G
S#B...##
#ICII.I#
#..#.#.#
.#..#.#.
7
PUSH RIGHT
MOVETO 2
CLIMB RIGHT
CLIMB RIGHT
GETDOWN RIGHT
CLIMB RIGHT
GETDOWN RIGHT
8 8
........
........
........
...G....
S#B.....
#ICIIIII
#..#.#.#
.#..#.#.
4
PUSH RIGHT
MOVETO 2
CLIMB RIGHT
CLIMB RIGHT
8 8
........
....#.#.
.....#.G
...#..#.
S#B....#
#ICIII.#
#..#.#.#
.#..#.#.
8
PUSH RIGHT
MOVETO 2
CLIMB RIGHT
CLIMB RIGHT
CLIMB RIGHT
GETDOWN RIGHT
CLIMB RIGHT
GETDOWN RIGHT
0 0

Sample Output

Game Over : Death by Hole
Game Over : Cleared
Game Over : Death by Walking Goal

Solution in JAVA (judge verdict: Wrong Answer)

import java.util.Scanner;

//The Tower
public class Main{

	int h, w, T, pi, pj, gi, gj, t;
	char[][] m;
	String[] str = {
			"Game Over : Cleared",
			"Game Over : Death by Hole",
			"Game Over : Death by Block",
			"Game Over : Death by Walking Goal",
			"Game Over : Gave Up"
	};
	String[][] cmd;
	
	int check(boolean soon){
		if(pi+1==gi&&pj==gj)return 0;
		if(m[pi+1][pj]=='B')return 1;
		if(m[pi][pj]!='.')return 2;
		if(m[gi][gj]!='G')return 3;
		if(soon)return 5;
		return t==T?4:5;
	}
	
	void push(int i, int j, int dir){
		if(m[i][j+dir]!='.')return;
		if(j+dir==0 || j+dir==w+1){
			m[i][j] = '.'; return;
		}
		m[i][j+dir] = m[i][j];
		m[i][j] = '.';
		if(m[i+1][j+dir]=='.')return;
		if(m[i][j+dir]=='I' || m[i+1][j+dir]=='I')push(i, j+dir, dir);
		return;
	}
	
	void command(){
		if("MOVETO".equals(cmd[t][0])){
			int s = Integer.parseInt(cmd[t][1]);
			if(s < 1 || w < s || pj==s)return;
			if(m[pi][s]!='.')return;
			boolean ok = true;
			for(int j=Math.min(pj, s);j<=Math.max(pj, s);j++)if(j!=s)ok&=m[pi+1][j]!='.';
			if(!ok)return;
			for(int j=Math.min(pj, s);j<=Math.max(pj, s);j++)if(j!=s && Character.isDigit(m[pi+1][j])){
				m[pi+1][j]--;
			}
			pj = s;
		}
		else if("GETDOWN".equals(cmd[t][0])){
			if(pi==h)return;
			if("LEFT".equals(cmd[t][1])){
				if(pj==1 || m[pi][pj-1]!='.' || m[pi+1][pj-1]!='.')return;
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pi++; pj--;
			}
			else{
				if(pj==w || m[pi][pj+1]!='.' || m[pi+1][pj+1]!='.')return;
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pi++; pj++;
			}
		}
		else if("CLIMB".equals(cmd[t][0])){
			if(pi==1)return;
			if("LEFT".equals(cmd[t][1])){
				if(m[pi][pj-1]=='.' || m[pi-1][pj-1]!='.' || m[pi-1][pj]!='.')return;
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pi--; pj--;
			}
			else{
				if(m[pi][pj+1]=='.' || m[pi-1][pj+1]!='.' || m[pi-1][pj]!='.')return;
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pi--; pj++;
			}
		}
		else if("PUSH".equals(cmd[t][0])){
			if("LEFT".equals(cmd[t][1])){
				if(m[pi][pj-1]=='.')return;
				boolean existC = false;
				int tail = pj;
				while(0 < tail && m[pi][tail-1]!='.'){
					if(m[pi][tail-1]=='C')existC = true;
					tail--;
				}
				if(tail==pj || existC)return;
				for(int j=tail;j<pj;j++)push(pi, j, -1);
			}
			else{
				if(m[pi][pj+1]=='.')return;
				boolean existC = false;
				int tail = pj;
				while(tail <= w && m[pi][tail+1]!='.'){
					if(m[pi][tail+1]=='C')existC = true;
					tail++;
				}
				if(tail==pj || existC)return;
				for(int j=tail;j>pj;j--)push(pi, j, 1);
			}
		}
		else if("PULL".equals(cmd[t][0])){
			if("LEFT".equals(cmd[t][1])){
				if(pj==1 || m[pi][pj+1]=='.' || m[pi][pj+1]=='C' || m[pi][pj-1]!='.')return;
				m[pi][pj] = m[pi][pj+1];
				m[pi][pj+1] = '.';
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pj--;
			}
			else{
				if(pj==w || m[pi][pj-1]=='.' || m[pi][pj-1]=='C' || m[pi][pj+1]!='.')return;
				m[pi][pj] = m[pi][pj-1];
				m[pi][pj-1] = '.';
				if(Character.isDigit(m[pi+1][pj]))m[pi+1][pj]--;
				pj++;
			}
		}
	}
	
	void autofunc(){
		boolean con = true;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(m[i][j]=='0')m[i][j]='.';
		while(con){
			con = false;
			for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(m[i][j]=='B'&&m[i-1][j]!='.'){
				con = true;
				m[i-1][j] = '.';
			}
			while(m[pi+1][pj]=='.')pi++;
			for(int i=h-1;i>=1;i--)for(int j=1;j<=w;j++)if(m[i][j]!='.'){
				int ni = i;
				while(m[ni+1][j-1]=='.'&&m[ni+1][j]=='.'&&m[ni+1][j+1]=='.'){
					con = true;
					m[ni+1][j] = m[ni][j];
					m[ni][j] = '.';
					ni++;
				}
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			h = sc.nextInt(); w = sc.nextInt();
			if((h|w)==0)break;
			m = new char[h+2][w+2];
			for(int j=0;j<w+2;j++)m[0][j]=m[h+1][j]='C';
			for(int i=1;i<=h;i++)m[i][0]=m[i][w+1]='.';
			for(int i=1;i<=h;i++){
				char[] c = sc.next().toCharArray();
				for(int j=1;j<=w;j++){
					m[i][j]=c[j-1];
					if(c[j-1]=='S'){
						m[i][j]='.'; pi = i; pj = j;
					}
					if(c[j-1]=='G'){
						gi = i; gj = j;
					}
				}
			}
			T = sc.nextInt();
			cmd = new String[T][2];
			for(int i=0;i<T;i++)for(int j=0;j<2;j++)cmd[i][j]=sc.next();
			int res = 5;
			for(t=0;;t++){
				res = check(false);
				if(res!=5)break;
				command();
//				print();
				res = check(true);
				if(res!=5)break;
				autofunc();
//				print();
			}
			System.out.println(str[res]);
		}
	}
	
	void print(){
		m[pi][pj] = 'S';
		for(int i=1;i<=h;i++)System.out.println(new String(m[i]));
		System.out.println();
		m[pi][pj] = '.';
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}