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<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[1010][1010];
char com[1010100];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int ijk[1010][1010][4];
int v[1010][1010][4];
int cost[1010100][4];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		scanf("%s",com);
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		int sr,sc;
		int gr,gc;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='S'){sr=i;sc=j;}
			if(str[i][j]=='G'){gr=i;gc=j;}
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<4;k++)ijk[i][j][k]=999999999;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<4;k++)v[i][j][k]=0;
		for(int i=0;i<=c;i++)for(int j=0;j<4;j++)cost[i][j]=999999999;
		for(int i=c-1;i>=0;i--){
			if(com[i]=='R')cost[i][1]=i+1;
			else cost[i][3]=i+1;
			for(int j=0;j<4;j++){
				if(com[i]=='R')cost[i][(j+1)%4]=min(cost[i][(j+1)%4],cost[i+1][j]);
				else cost[i][(j+3)%4]=min(cost[i][(j+3)%4],cost[i+1][j]);
			}
		}
		priority_queue<pair<pair<int,int>,pair<int,int> > >Q;
		ijk[sr][sc][0]=0;
		Q.push(make_pair(make_pair(0,0),make_pair(sr,sc)));
		while(Q.size()){
			int co=-Q.top().first.first;
			int dir=Q.top().first.second;
			int row=Q.top().second.first;
			int col=Q.top().second.second;
			Q.pop();
			if(v[row][col][dir])continue;
			v[row][col][dir]=1;
			if(0<=row+dx[dir]&&row+dx[dir]<a&&0<=col+dy[dir]&&col+dy[dir]<b&&str[row+dx[dir]][col+dy[dir]]!='#'&&!v[row+dx[dir]][col+dy[dir]][dir]&&ijk[row+dx[dir]][col+dy[dir]][dir]>co){
				ijk[row+dx[dir]][col+dy[dir]][dir]=co;
				Q.push(make_pair(make_pair(-co,dir),make_pair(row+dx[dir],col+dy[dir])));
			}
			if(!v[row][col][(dir+1)%4]&&ijk[row][col][(dir+1)%4]>cost[co][1]&&cost[co][1]<9999999){
				ijk[row][col][(dir+1)%4]=cost[co][1];
				Q.push(make_pair(make_pair(-cost[co][1],(dir+1)%4),make_pair(row,col)));
			}
			if(!v[row][col][(dir+3)%4]&&ijk[row][col][(dir+3)%4]>cost[co][3]&&cost[co][3]<9999999){
				ijk[row][col][(dir+3)%4]=cost[co][3];
				Q.push(make_pair(make_pair(-cost[co][3],(dir+3)%4),make_pair(row,col)));
			}
		}
		if(v[gr][gc][0]||v[gr][gc][1]||v[gr][gc][2]||v[gr][gc][3])printf("Yes\n");
		else printf("No\n");
	}
}