Problem: A robot in a two-dimensional maze again. The maze has an entrance and an exit this time, though.

Just as in the previous problem, the maze is made up of H × W grid cells, its upper side faces north, and each cell is either empty or wall. Unlike the previous, on the other hand, one of the empty cells is connected to the entrance and another to the exit.

The robot is rather complex - there is some control, but not full. It is associated with a controller that has two buttons, namely forward and turn. The forward button moves the robot forward to the next cell, if possible. The robot can not move into a wall nor outside the maze. The turn button turns the robot as programmed. Here the program is a finite sequence of N commands, each of which is either 'L' (indicating a left turn) or 'R' (a right turn). The first turn follows the first command; the second turn follows the second command; similar for the following turns. The turn button stops working once the commands are exhausted; the forward button still works in such a case though. The robot always turns by 90 degrees at once.

The robot is initially put on the entrance cell, directed to the north. Your mission is to determine whether it can reach the exit cell if controlled properly.



Input

The input is a sequence of datasets. Each dataset is formatted as follows.

H W N
s1 ... sN
c1,1c1,2...c1,W
...
cH,1cH,2...cH,W


The first line of a dataset contains three integers H, W and N (1 ≤ H, W ≤ 1,000, 1 ≤ N ≤ 1,000,000).

The second line contains a program of N commands.

Each of the following H lines contains exactly W characters. Each of these characters represents a cell of the maze. "." indicates empty, "#" indicates a wall, "S" indicates an entrance, and "G" indicates an exit. There is exactly one entrance cell and one exit cell.

The end of input is indicated by a line with three zeros.

Output

For each dataset, output whether the robot can reach the exit in a line: "Yes" if it can or "No" otherwise (without quotes).

Examples

Input

2 2 1
L
G.
#S
2 2 2
RR
G.
.S
3 3 6
LLLLLL
G#.
...
.#S
0 0 0


Output

Yes
No
Yes


Input

2 2 1
L
G.
S
2 2 2
RR
G.
.S
3 3 6
LLLLLL
G#.
...
.#S
0 0 0


Output

Yes
No
Yes

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <queue>
using namespace std;

const int INF = 1 << 25;
int direction[1000010][4];
int memo[1010][1010][4];
vector<int> direct[4];
char field[1010][1010];
string command;

int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1,  0, -1};

typedef pair<int, int> P;
typedef pair<P, int> state;  // position, direcion
typedef pair<int, state> data;


int main(){
  int H, W, N;
  int sy, sx;
  int gy, gx;
  while(cin >> H >> W >> N && (H || W || N)){
    int dir = 0;
    cin >> command;
    
    
    for(int i = 0; i < 1000010; i++){
      for(int j = 0; j < 4; j++){
	direction[i][j] = INF;
      }
    }
    for(int i = 0; i < 1010; i++){
      for(int j = 0; j < 1010; j++){
	field[i][j] = '#';
	for(int k = 0; k < 4; k++){
	  memo[i][j][k] = INF;
	}
      }
    }

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> field[i+1][j+1];
	if(field[i+1][j+1] == 'S'){
	  sy = i + 1;
	  sx = j + 1;
	  field[i+1][j+1] = '.';
	}
	if(field[i+1][j+1] == 'G'){
	  gy = i + 1;
	  gx = j + 1;
	  field[i+1][j+1] = '.';
	}
      }
    }
    
    for(int i = 0; i < 4; i++) direct[i].clear();
    for(int i = 0; i < N; i++){
      direct[dir].push_back(i);
      if(command[i] == 'R') dir = (dir + 1) %4 ;
      else dir = (dir + 3) % 4;
    }
    direct[dir].push_back(N);
    
    for(int i = 0; i <= N; i++){
      for(int j = 0; j < 4; j++){
	vector<int>::iterator iter
	  = upper_bound(direct[j].begin(), direct[j].end(), i);
	if(iter != direct[j].end()) direction[i][j] = *iter;
      }
    }
    
    memo[sy][sx][0] = 0;
    priority_queue<data, vector<data>, greater<data> > que;
 
    bool flag=false;
    que.push(data(0, state(P(sy, sx), 0)));
    while(!que.empty()){
      data d = que.top();
      int cost = d.first;
      state s = d.second;
      int y = s.first.first;
      int x = s.first.second;
      int dir = s.second;
      que.pop();
      
      if(s.first.first == gy && s.first.second==gx){
	flag = true;
	break;
      }
      if(cost > memo[y][x][dir]) continue;

      
      
      for(int i=0;i<4;i++){
	int nextturn = direction[cost][i];
	int y2 = y + dy[i];
	int x2 = x + dx[i];
	if(field[y2][x2] == '#') continue;
	if(memo[y2][x2][i] > nextturn){
	  memo[y2][x2][i] = nextturn;
	  que.push(data(nextturn, state(P(y2, x2), i)));
	}
	
      }
      int y2 = y + dy[dir];
      int x2 = x + dx[dir];
      if(field[y2][x2] != '#' && memo[y2][x2][dir] > cost){
	memo[y2][x2][dir] = cost;
	que.push(data(cost, state(P(y2, x2), dir)));
      }
    }
    if(flag){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}