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 <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>

using namespace std;

class S{
public:
  int y, x, d;
  S(){}
  S(int y, int x, int d) : y(y), x(x), d(d) {}
  bool operator < (const S &s) const {
    if(y == s.y){
      if(x == s.x){
        return d < s.d;
      }
      return x < s.x;
    }
    return y < s.y;
  }
};

typedef pair<int, S> P;

const int N = 1000;
const int M = 1000001;
const int MAX_V = N * N * 4;
const int INF = 1 << 28;

int V, h, w, n, gx, gy;
int G[M][4];
int d[N][N][4];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
char dat[N][N];

bool dijkstra(S s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d[0][0], d[N][0], INF);
  d[s.y][s.x][s.d] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    S v = p.second;
    if(v.y == gy && v.x == gx) return true;
    if(d[v.y][v.x][v.d] < p.first) continue;
    for(int i=0;i<4;i++){
      int cost = G[p.first][i];
      if(cost == -1) continue;
      int ny = v.y + dy[i];
      int nx = v.x + dx[i];
      if(ny < 0 || ny >= h) continue;
      if(nx < 0 || nx >= w) continue;
      if(dat[ny][nx] == '#') continue;
      if(d[ny][nx][i] > cost){
        d[ny][nx][i] = cost;
        que.push(P(d[ny][nx][i], S(ny, nx, i)));
      }
    }
  }
  return false;
}

int main(){
  while(cin >> h >> w >> n && (h|w|n)){
		fill(G[0], G[M], -1);
    string L;
    cin >> L;
    int sy, sx;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> dat[i][j];
        if(dat[i][j] == 'S'){
          sy = i;
          sx = j;
          dat[i][j] = '.';
        }
        if(dat[i][j] == 'G'){
          gy = i;
          gx = j;
          dat[i][j] = '.';
        }
      }
    }
    vector<int> vec[4];
    vec[0].push_back(0);
		vector<int> dir;
		dir.push_back(0);
    for(int i=0;i<n;i++){
			int cdir = dir.back();
      if(L[i] == 'L') dir.push_back((cdir + 3) % 4);
      else dir.push_back((cdir + 1) % 4);
      vec[dir.back()].push_back(i+1);
    }
		for(int i=0;i<=n;i++){
			for(int j=0;j<4;j++){
				int p = lower_bound(vec[j].begin(), vec[j].end(), i) - vec[j].begin();
				if(p < (int)vec[j].size()) G[i][j] = vec[j][p];
			}
    }
		/*
		for(int i=0;i<=n;i++){
			for(int j=0;j<4;j++){
				cout << G[i][j] << ' ';
			}
			cout << endl;
		}
		*/
		cout << (dijkstra(S(sy, sx, 0)) ? "Yes" : "No") << endl;
  }
	return 0;
}