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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char ba[1000][1000];
int dirdis[1000001][4];
int dirtable[1000001];

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

bool visited[1000][1000][4];

struct P {
  int y,x,d;
  int i;
};

const bool operator<(const P &a, const P &b) {
  return a.i > b.i;
}

int main() {
  int h,w,n;
  while(cin>>h>>w>>n,h||w||n) {
    string s;
    cin >> s;
    int sx,sy,gx,gy;
    int sd = 0;
    REP(i, h) {
      REP(j, w) {
        cin >> ba[i][j];
        if (ba[i][j] == 'S') {
          sy = i;
          sx = j;
        } else if (ba[i][j] == 'G') {
          gy = i;
          gx = j;
        }
      }
    }
    REP(i, n) {
      if (s[i] == 'L')
        dirtable[i+1] = (dirtable[i] + 3) % 4;
      else
        dirtable[i+1] = (dirtable[i] + 1) % 4;
    }
    int last[4];
    memset(last, -1, sizeof(last));
    for (int i=n; i>=0; --i) {
      REP(j, 4) {
        if (last[j] >= 0)
          dirdis[i][j] = last[j] - i;
        else
          dirdis[i][j] = -1;
      }
      last[dirtable[i]] = i;
    }
    priority_queue<P> Q;
    Q.push((P){sy,sx,sd,0});
    memset(visited,0,sizeof(visited));
    bool f = 0;
    while(!Q.empty()) {
      P now = Q.top(); Q.pop();
      int y=now.y, x=now.x, d=now.d;
      if (visited[y][x][d]) continue;
      visited[y][x][d] = 1;

      //printf("(%d,%d):%d:%d\n",x,y,d,now.i);
      
      if (y==gy&&x==gx) {
        f = 1;
        break;
      }
      
      REP(k,4) {
        if (d==k) continue;
        if (dirdis[now.i][k] !=-1) {
          Q.push((P){y,x,k,now.i+dirdis[now.i][k]});
        }
      }
      int yy = y+dy[d];
      int xx = x+dx[d];
      if (yy<0||yy>=h||xx<0||xx>=w||ba[yy][xx]=='#') continue;
      Q.push((P){yy,xx,d,now.i});
    }
    if (f)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}