#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
bool Hs[100000];
bool Ws[100000];
int HPT[100001];
int HMT[100001];
int HPF[100001];
int HMF[100001];
int WPT[100001];
int WMT[100001];
int WPF[100001];
int WMF[100001];
pair<int,int> X[6];
void Calc(){
	int H = rei();
	int W = rei();
	int Q = rei();
	string S = res();
	string T = res();
	for(int i=0;i<H;i++){
		Hs[i] = S[i] == 'E';
	}
	for(int i=0;i<W;i++){
		Ws[i] = T[i] == 'S';
	}	
	for(int i=0;i<H;i++){
		if(Hs[i]){
			HMT[i+1] = i+1;
			HMF[i+1] = HMF[i];
		}
		else{
			HMF[i+1] = i+1;
			HMT[i+1] = HMT[i];
		}
	}
	HPF[H] = H;
	HPT[H] = H;
	for(int i=H-1;i>=0;i--){
		if(Hs[i]){
			HPT[i] = i;
			HPF[i] = HPF[i+1];
		}
		else{
			HPF[i] = i;
			HPT[i] = HPT[i+1];
		}
	}
	for(int i=0;i<W;i++){
		if(Ws[i]){
			WMT[i+1] = i+1;
			WMF[i+1] = WMF[i];
		}
		else{
			WMF[i+1] = i+1;
			WMT[i+1] = WMT[i];
		}
	}
	WPF[W] = W;
	WPT[W] = W;
	for(int i=W-1;i>=0;i--){
		if(Ws[i]){
			WPT[i] = i;
			WPF[i] = WPF[i+1];
		}
		else{
			WPF[i] = i;
			WPT[i] = WPT[i+1];
		}
	}
	for(int query=0;query<Q;query++){
		int start = 0;
		stack<tuple<int,int,bool,int,int>> sp;
		int hb = rei()-1;
		int wb = rei()-1;
		int ha = rei()-1;
		int wa = rei()-1;
		sp.push(make_tuple(hb,wb,true,0,0));
		sp.push(make_tuple(hb,wb,false,0,0));
		int nextx,nexty;
		int ans = 1000000000;
		while(!sp.empty()){
			tuple<int,int,bool,int,int> t = sp.top();
			sp.pop();
			int x = get<0>(t);
			int y = get<1>(t);
			int coun = get<3>(t);
			int cost = get<4>(t);
			int d = 0;
			if(get<2>(t)){
				if(Ws[y]){
					if(ha > x){
						if(HPF[ha] != H){
							nextx = HPF[ha];
							nexty = y;
							X[d++] = {nextx,nexty};
						}
						if(HPT[ha] != H){
							nextx = HPT[ha];
							nexty = y;
							X[d++] = {nextx,nexty};
						}
					}
					if(HPF[x] != x && HPF[x] != H){
						nextx = HPF[x];
						nexty = y;
						X[d++] = {nextx,nexty};
					}
					if(HPT[x] != x && HPT[x] != H){
						nextx = HPT[x];
						nexty = y;
						X[d++] = {nextx,nexty};
					}
				}
				else{
					if(ha < x){
						if(HMF[ha+1] != 0){
							nextx = HMF[ha+1]-1;
							nexty = y;
							X[d++] = {nextx,nexty};
						}
						if(HMT[ha+1] != 0){
							nextx = HMT[ha+1]-1;
							nexty = y;
							X[d++] = {nextx,nexty};
						}
					}
					if(HMF[x+1] != x+1 && HMF[x+1] != 0){
						nextx = HMF[x+1]-1;
						nexty = y;
						X[d++] = {nextx,nexty};
					}
					if(HMT[x+1] != x+1 && HMT[x+1] != 0){
						nextx = HMT[x+1]-1;
						nexty = y;
						X[d++] = {nextx,nexty};
					}
				}
			}
			else{
				if(Hs[x]){
					if(wa > y){
						if(WPF[wa] != W){
							nexty = WPF[wa];
							nextx = x;
							X[d++] = {nextx,nexty};
						}
						if(WPT[wa] != W){
							nexty = WPT[wa];
							nextx = x;
							X[d++] = {nextx,nexty};
						}
					}
					if(WPF[y] != y && WPF[y] != W){
						nexty = WPF[y];
						nextx = x;
						X[d++] = {nextx,nexty};
					}
					if(WPT[y] != y && WPT[y] != W){
						nexty = WPT[y];
						nextx = x;
						X[d++] = {nextx,nexty};
					}
				}
				else{
					if(wa < y){
						if(WMF[wa+1] != 0){
							nexty = WMF[wa+1]-1;
							nextx = x;
							X[d++] = {nextx,nexty};
						}
						if(WMT[wa+1] != 0){
							nexty = WMT[wa+1]-1;
							nextx = x;
							X[d++] = {nextx,nexty};
						}
					}
					if(WMF[y+1] != y+1 && WMF[y+1] != 0){
						nexty = WMF[y+1]-1;
						nextx = x;
						X[d++] = {nextx,nexty};
					}
					if(WMT[y+1] != y+1 && WMT[y+1] != 0){
						nexty = WMT[y+1]-1;
						nextx = x;
						X[d++] = {nextx,nexty};
					}
				}
			}
			if(coun == 4){
				for(int i=0;i<d;i++){
					if(X[i].first == ha && X[i].second == wa){
						ans = min(ans,abs(X[i].first-x)+abs(X[i].second-y)+cost);
					}
				}
			}
			else{
				for(int i=0;i<d;i++){
					if(X[i].first == ha && X[i].second == wa){
						ans = min(ans,abs(X[i].first-x)+abs(X[i].second-y)+cost);
					}
					else{
						sp.push(make_tuple(X[i].first,X[i].second,!get<2>(t),coun+1,abs(X[i].first-x)+abs(X[i].second-y)+cost));
					}
				}
			}
		}
		if(ans == 1000000000){
			cout << "-1\n"; 
		}
		else{
			cout << ans << "\n"; 
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 5072