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 <queue>
#include <set>
#include <cstring>
#include <cstdio>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

template<class T> T getAs(){ T v; std::cin >> v; return v; }
int getInt(){ return getAs<int>(); }

using namespace std;

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

using namespace std;

const int _dx[] = { 0, 1, 0,-1};
const int _dy[] = {-1, 0, 1, 0};

enum DIR{
  NORTH = 0,
  EAST  = 1,
  SOUTH = 2,
  WEST  = 3
};

string s;
string g[1000];
int memo[1000][1000][4];
int nextdir[1000010][4];
int w, h, n;

bool cango(int x, int y, int d){
  int xx = x + _dx[d];
  int yy = y + _dy[d];

  return ISIN(xx, yy, w, h) && g[yy][xx] == '.';
}

struct data{
  int x;
  int y;
  int d;
  int cnt;

  data(int a, int b, int c, int e) : x(a), y(b), d(c), cnt(e) {}
};

bool operator < (const data &lhs, const data &rhs){
  return lhs.cnt > rhs.cnt;
}

int main(){
  while(true){
    h = getInt();
    w = getInt();
    n = getInt();

    int sx, sy, sd = NORTH;
    int gx, gy;

    if(h + w + n == 0) break;

    cin >> s;

    REP(i,h){
      cin >> g[i];

      REP(j,w){
        if(g[i][j] == 'S'){
          sx = j; sy = i; g[i][j] = '.';
        }else if(g[i][j] == 'G'){
          gx = j; gy = i; g[i][j] = '.';
        }
      }
    }

    memset(memo, -1, sizeof(memo));

    for(int i = n - 1; i >= 0; i--){
      REP(j,4) nextdir[i][j] = n + 2;

      nextdir[i][s[i] == 'L' ? 3 : 1] = i + 1;
      nextdir[i][0] = i;
      if(i != n - 1){
        REP(j,4){
          int k = (j + (s[i] == 'L' ? 3 : 1)) % 4;
          nextdir[i][k] = min(nextdir[i][k], nextdir[i + 1][j]);
        }
      }
    }

    /*
    REP(j,n) printf("  %c", s[j]); puts("");
    REP(i,4){
      REP(j,n){
        printf("%2d ", nextdir[j][i]);
      }
      puts("");
    }
    REP(i,h) cout << g[i] << endl;
    */

    bool ans = false;
    priority_queue<data> pq;
    pq.push(data(sx, sy, sd, 0));

    while(pq.size()){
      data dt = pq.top(); pq.pop();
      int x = dt.x;
      int y = dt.y;
      int d = dt.d;
      int cnt = dt.cnt;

      if(memo[y][x][d] != -1) continue;
      memo[y][x][d] = cnt;
      //printf("%d %d %d %d\n", x, y, d, cnt);

      if(cnt != n){
        REP(i,4) if(nextdir[cnt][i] != n + 2){
          int dd = (d + i) % 4;
          if(memo[y][x][dd] == -1) pq.push(data(x, y, dd, nextdir[cnt][i]));
        }
      }

      while(cango(x, y, d)){
        x += _dx[d]; y += _dy[d];
        if(gx == x && gy == y){ ans = true; goto end; }
        if(cnt != n){
          int nextd = (d + (s[cnt] == 'L' ? 3 : 1)) % 4;
          if(memo[y][x][nextd] == -1){
            pq.push(data(x, y, nextd, cnt + 1));
          }
        }
      }
    }

  end:;
    puts(ans ? "Yes" : "No");
  }

  return 0;
}