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 <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> P2;
typedef pair<int,P2> P3;
const int MAX=1000000007;

int dy[4]={-1,0,1,0},dx[4]={0,-1,0,1};
bool check(int n,int m,int x,int y) {
  if(x<0 || x>=n) return false;
  if(y<0 || y>=m) return false;
  return true;
}
int d[1001][1001][4];
priority_queue<P3,vector<P3>,greater<P3> > que;

int main() {
  int n,m,k;
  while(cin >> n >> m >> k && (n||m||k)) {
    while(!que.empty()) que.pop();

    string c;
    string s[n];
    cin >> c;
    for(int i=0; i<n; i++) cin >> s[i];
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	for(int l=0; l<4; l++) d[i][j][l]=MAX;
      }
    }

    int sx,sy,tx,ty;
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	if(s[i][j]=='S') {
	  sx=i;sy=j;
	}
	if(s[i][j]=='G') {
	  tx=i;ty=j;
	}
      }
    }

    que.push(P3(0,P2(1,P(sx,sy))));
    d[sx][sy][1]=0;
    bool ck=false;
    while(!que.empty()) {
      P3 p=que.top();que.pop();
      int j=p.F,z=p.S.F,nx=p.S.S.F,ny=p.S.S.S;
      if(nx==tx && ny==ty) {
	ck=true;
	break;
      }


      int x=nx+dx[z],y=ny+dy[z];
      if(check(n,m,x,y) && s[x][y]!='#' && d[x][y][z]>j) {
	d[x][y][z]=j;
	que.push(P3(j,P2(z,P(x,y))));
      }
      
      x=nx;y=ny;
      int z2=z;
      bool b[4];
      memset(b,false,sizeof(b));
      b[z]=true;
      for(int i=j; i<k; i++) {
	if(c[i]=='L') z2--;
	else z2++;
	if(z2<0) z2+=4;
	else if(z2>=4) z2-=4;
	if(b[z2]) continue;
	b[z2]=true;
	if(d[x][y][z2]>i+1) {
	  d[x][y][z2]=i+1;
	  que.push(P3(i+1,P2(z2,P(x,y))));
	}
      }
    }
    if(ck) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}