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:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU

int d[1010][1010][4];
signed main(){
	int n,m,q;
	while(cin>>n>>m>>q,n){
		string s;
		cin>>s;
		vs in(n);
		rep(i,n)cin>>in[i];
		int sx,sy,gx,gy;
		rep(i,n)rep(j,m)if(in[i][j]=='S'){
			sx=i,sy=j;
		}else if(in[i][j]=='G'){
			gx=i,gy=j;
		}
		vvi ne(s.size()+1,vi(4,inf));
		for(int i=s.size()-1;i>=0;i--){
			int t=1;
			if(s[i]=='R')t=-1;
			rep(j,4)ne[i][j]=ne[i+1][(j+4+t)%4];
			if(s[i]=='R')ne[i][1]=i+1;
			if(s[i]=='L')ne[i][3]=i+1;
		}
		// show2d(ne);
		
		rep(i,1010)rep(j,1010)rep(k,4)
			d[i][j][k]=inf;
		d[sx][sy][3]=0;
		priority_queue<tp>q;
		q.push(tp(0,sx,sy,3));
		while(!q.empty()){
			Def cost,x,y,to;
			tie(cost,x,y,to)=q.top();
			cost*=-1;
			q.pop();
			if(cost>d[x][y][to])continue;
			rep(k,4){
				int nx=x+dx[k];
				int ny=y+dy[k];
				if(nx<0||ny<0||nx>=n||ny>=m)continue;
				if(in[nx][ny]=='#')continue;
				int nto=k;
				int ncost=ne[cost][(k-to+4)%4];
				if(k==to)ncost=cost;
				if(ncost==inf)continue;
				if(ncost<d[nx][ny][nto]){
					d[nx][ny][nto]=ncost;
					q.push(tp(-ncost,nx,ny,nto));
				}
			}
		}
		rep(i,4)if(d[gx][gy][i]-inf){
			cout<<"Yes"<<endl;
			goto end;
		}
		cout<<"No"<<endl;
		end:;
	}
}