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>
#define MAX 1024
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[4]={0,1,0,-1};
const int dy[4]={-1,0,1,0};

string s;
string grid[MAX];
int h,w,n;
int d[MAX][MAX][4];
int sy,sx,gx,gy;
int a[1000001];
int mem[1000001][4];

class State{
  public:
    int y,x,d,c;
    State(int y,int x,int d,int c):y(y),x(x),d(d),c(c){}
    bool operator<(State s)const{
      return s.c<c;
    }
};

bool in(int y,int x){
  if(x<0 || y<0 || w<=x || h<=y)return false;
  return true;
}

string solve(){
  fill(a,a+n,0);
  FOR(i,1,n+1){
    if(s[i-1]=='R')a[i]=a[i-1]+1;
    else a[i]=a[i-1]+3;
    a[i]%=4;
  }
  int A=-1,B=-1,C=-1,D=-1;
  RFOR(i,n+1,0){
    mem[i][0]=A;
    mem[i][1]=B;
    mem[i][2]=C;
    mem[i][3]=D;
    if(a[i]==0)A=i;
    if(a[i]==1)B=i;
    if(a[i]==2)C=i;
    if(a[i]==3)D=i;
  }

  FOR(i,0,MAX)FOR(j,0,MAX)FOR(k,0,4)d[i][j][k]=inf;
  priority_queue<State> pq;
  FOR(i,0,h){
    FOR(j,0,w){
      if(grid[i][j]=='S'){ sy=i;sx=j; }
      if(grid[i][j]=='G'){ gy=i;gx=j; }
    }
  }
  d[sy][sx][0]=0;
  pq.push(State(sy,sx,0,0));

  while(pq.size()){
    State u = pq.top();
    pq.pop();

    if(u.y==gy && u.x==gx)return "Yes";
    if(d[u.y][u.x][u.d]<u.c)continue;

    int ny=u.y+dy[u.d],nx=u.x+dx[u.d],nd=u.d;
    if(in(ny,nx) && grid[ny][nx]!='#'){
      if(u.c<d[ny][nx][nd]){
        d[ny][nx][nd]=u.c;
        pq.push(State(ny,nx,nd,u.c));
      }
    }
    if(n<u.c)continue;
    FOR(i,0,4){
      if(mem[u.c][i]==-1)continue;
      int cost=mem[u.c][i];
      if(cost<d[u.y][u.x][i]){
        d[u.y][u.x][i]=cost;
        pq.push(State(u.y,u.x,i,cost));
      }
    }
  }
  return "No";
}

int main()
{
  while(cin>>h>>w>>n && h){
    cin>>s;
    FOR(i,0,h)cin>>grid[i];
    cout<<solve()<<endl;
  }
  return 0;
}