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 dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

template<typename Functor>
struct functor_traits{
	template<typename C,typename Ret,typename Arg,typename... Args>
		static Arg helper(Ret(C::*)(Arg,Args...));
	template<typename C,typename Ret,typename Arg,typename... Args>
		static Arg helper(Ret(C::*)(Arg,Args...)const);
	//using first_argument_type=decltype(helper(&Functor::operator()));
	typedef decltype(helper(&Functor::operator())) first_argument_type;
};
template<typename Compare,typename T=typename functor_traits<Compare>::first_argument_type>
priority_queue<T,vector<T>,Compare> make_priority_queue(Compare comp){
	return priority_queue<T,vector<T>,Compare>(move(comp));
}

int main()
{
	const int di[]={-1,0,1,0},dj[]={0,-1,0,1};
	
	for(int h,w,n;cin>>h>>w>>n && h|w|n;){
		string t; cin>>t;
		vs grid(h);
		rep(i,h) cin>>grid[i];
		
		vi ds(n+1);
		rep(i,n){
			if(t[i]=='L') ds[i+1]=(ds[i]+1)%4;
			if(t[i]=='R') ds[i+1]=(ds[i]+3)%4;
		}
		vvi next(n+1,vi(4));
		{
			vi tmp(4,INF);
			per(i,n+1){
				tmp[ds[i]]=i;
				rep(j,4) next[i][j]=tmp[j];
			}
		}
		
		// (i,j,d,p)
		auto pq=make_priority_queue(
			[](tuple<int,int,int,int> a,tuple<int,int,int,int> b){return get<3>(a)>get<3>(b);}
		);
		rep(i,h) rep(j,w) if(grid[i][j]=='S') pq.emplace(i,j,0,0);
		vvi vis(h,vi(w));
		bool res=false;
		while(pq.size()){
			int i,j,d,p; tie(i,j,d,p)=pq.top(); pq.pop();
			if(i<0 || h<=i || j<0 || w<=j || p==INF || grid[i][j]=='#' || (vis[i][j]>>d&1)) continue;
			vis[i][j]|=1<<d;
			if(grid[i][j]=='G'){
				res=true;
				break;
			}
			rep(k,4) pq.emplace(i+di[k],j+dj[k],k,next[p][k]);
		}
		cout<<(res?"Yes":"No")<<endl;
	}
}