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>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int H, W, N;
string s;
string c[1001];
int nex[4][1001000];
int mincost[1001][1001];
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

struct State {
  int y, x, cost;
  State(){}
  State(int y, int x, int cost):y(y), x(x), cost(cost){}
  bool operator < (const State& s) const {
    return cost > s.cost;
  }
};

bool in(int y, int x) {
  return 0<=y&&y<H&&0<=x&&x<W&&c[y][x]!='#';
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> H >> W >> N, H) {
    cin >> s;
    rep(i, H) cin >> c[i];

    vint sum(N+1);
    rep(i, N) {
      if(s[i] == 'L') sum[i+1] = sum[i]+1;
      else sum[i+1] = sum[i]+3;
      sum[i+1] %= 4;
    }
    memset(nex, -1, sizeof(nex));
    rep(i, 4) {
      int p = -1;
      for(int j = N; j >= 0; --j) {
	if(sum[j] == i) p = j;
	if(~p) nex[i][j] = p-j;
      }
    }

    int sy, sx, gy, gx;
    rep(i, H) rep(j, W) {
      if(c[i][j] == 'S') sy = i, sx = j;
      else if(c[i][j] == 'G') gy = i, gx = j;
    }

    priority_queue<State> que;
    fill(mincost[0], mincost[1001], inf);
    mincost[sy][sx] = 0;
    que.push(State(sy, sx, 0));
    while(!que.empty()) {
      State st = que.top(); que.pop();
      if(st.y == gy && st.x == gx) break;
      if(mincost[st.y][st.x] < st.cost) continue;
      rep(i, 4) {
	int ny = st.y + dy[i], nx = st.x + dx[i];
	if(!in(ny, nx)) continue;
	if(nex[i][st.cost] == -1) continue;
	if(st.cost+nex[i][st.cost] < mincost[ny][nx]) {
	  mincost[ny][nx] = st.cost + nex[i][st.cost];
	  que.push(State(ny, nx, mincost[ny][nx]));
	}
      }
    }
    cout << (mincost[gy][gx] == inf ? "No" : "Yes") << endl;
  }

  return 0;
}