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:
/*
 * 2325.cc: Mysterious Maze
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 1000000;

int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1};

const int INF = 1 << 30;

/* typedef */

struct Stat {
  int d, x, y, di;
  Stat() {}
  Stat(int _d, int _x, int _y, int _di): d(_d), x(_x), y(_y), di(_di) {}
  bool operator<(const Stat &s) const { return d < s.d; }
  bool operator>(const Stat &s) const { return d > s.d; }
};

/* global variables */

bool flds[MAX_H][MAX_W];
int dirs[MAX_N + 1], nxtds[MAX_N + 1][4];
int dists[MAX_H][MAX_W][4];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int h, w, n;
    cin >> h >> w >> n;
    if (h == 0) break;

    string sop;
    cin >> sop;

    int nds[] = {INF, INF, INF, INF};
    dirs[0] = 1;
    for (int i = 0, di = 0; i < n; i++)
      dirs[i + 1] =  (dirs[i] + (sop[i] == 'L' ? 1 : 3)) % 4;
    for (int i = n; i >= 0; i--) {
      nds[dirs[i]] = i;
      for (int j = 0; j < 4; j++) nxtds[i][j] = nds[j];
      //printf("%d:", i);
      //for (int j = 0; j < 4; j++) printf(" %d", nxtds[i][j]); putchar('\n');
    }

    int sx, sy, gx, gy;
    memset(flds, true, sizeof(flds));
    
    for (int y = 0; y < h; y++) {
      string s;
      cin >> s;
      for (int x = 0; x < w; x++)
	switch (s[x]) {
	case 'S': sx = x; sy = y; break;
	case 'G': gx = x; gy = y; break;
	case '#': flds[y][x] = false; break;
	}
    }

    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++)
	for (int di = 0; di < 4; di++) dists[y][x][di] = INF;
    dists[sy][sx][1] = 0;
    
    priority_queue<Stat,vector<Stat>,greater<Stat> > q;
    q.push(Stat(0, sx, sy, 1));
    bool ans = false;
    
    while (! q.empty()) {
      Stat u = q.top(); q.pop();
      if (dists[u.y][u.x][u.di] != u.d) continue;
      //printf("(%d,%d,%d)=%d\n", u.x, u.y, u.di, u.d);

      if (u.x == gx && u.y == gy) {
	ans = true;
	break;
      }

      for (int vdi = 0; vdi < 4; vdi++) {
	int vx = u.x + dxs[vdi], vy = u.y + dys[vdi];
	if (vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vy][vx]) {
	  int vd = nxtds[u.d][vdi];
	  if (dists[vy][vx][vdi] > vd) {
	    dists[vy][vx][vdi] = vd;
	    q.push(Stat(vd, vx, vy, vdi));
	  }
	}
      }
    }

    cout << (ans ? "Yes" : "No") << endl;
  }
  
  return 0;
}