#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

vector<P> nullvP;

struct Graph{
	int V;
	vector<vector<P>> G;
	void init(int _V){
		V = _V;
		G.clear();
		rep(i,V+1){
			G.pb(nullvP);
		}
	}
	void add_edge(int a,int b,int w = 1){
		//cout << a << " " << b << " " << w << endl;
		G[a].pb(P(b,w));
		//G[b].pb(P(a,w));
	}
	int dijkstra(int s,int t){
		//cout << "(s,t)=" << s << "," << t << endl;
		bool used[52];
		int dist[52];
		priority_queue<P,vector<P>,greater<P>> que;
		rep(i,52){
			used[i] = false;
			dist[i] = INF;
		}
		dist[s] = 0;
		que.push(P(0,s));
		while(!que.empty()){
			P p = que.top(); que.pop();
			//cout << p.fr << " " << p.sc << endl;
			if(used[p.sc])continue;
			used[p.sc] = true;
			for(P ed: G[p.sc]){
				if(dist[ed.fr] > dist[p.sc]+ed.sc){
					dist[ed.fr] = dist[p.sc]+ed.sc;
					que.push(P(dist[ed.fr],ed.fr));
				}
			}
		}
		return dist[t];
	}
}G;

int main(){
	static int n,m,q;
	static string s,t;
	//static int a[200010],b[200010],c[200010],d[200010];
	scanf("%d%d%d",&n,&m,&q);
	cin >> s >> t;
	/*rep1(i,q){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}*/
	
	static int lw[100010],rw[100010],le[100010],re[100010];
	static int ln[100010],rn[100010],ls[100010],rs[100010];
	lw[0] = le[0] = 0;
	rep1(i,n){
		lw[i] = lw[i-1];
		le[i] = le[i-1];
		if(s[i-1] == 'W')lw[i] = i;
		else le[i] = i;
	}
	ln[0] = ls[0] = 0;
	rep1(i,m){
		ln[i] = ln[i-1];
		ls[i] = ls[i-1];
		if(t[i-1] == 'N')ln[i] = i;
		else ls[i] = i;
	}
	rw[n+1] = re[n+1] = n+1;
	rrep1(i,n){
		rw[i] = rw[i+1];
		re[i] = re[i+1];
		if(s[i-1] == 'W')rw[i] = i;
		else re[i] = i;
	}
	rn[m+1] = rs[m+1] = m+1;
	rrep1(i,m){
		rn[i] = rn[i+1];
		rs[i] = rs[i+1];
		if(t[i-1] == 'N')rn[i] = i;
		else rs[i] = i;
	}
	
	//rep1(i,n)cout << lw[i] << " " << rw[i] << " " << le[i] << " " << re[i] << endl;
	//rep1(i,m)cout << ln[i] << " " << rn[i] << " " << ls[i] << " " << rs[i] << endl;
	
	rep1(loop,q){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		vector<int> X,Y;
		X.pb(a); X.pb(c);
		if(s[a-1] == 'E'){
			if(lw[a] != 0)X.pb(lw[a]);
			if(rw[a] != n+1)X.pb(rw[a]);
		}
		else {
			if(le[a] != 0)X.pb(le[a]);
			if(re[a] != n+1)X.pb(re[a]);
		}
		if(s[c-1] == 'E'){
			if(lw[c] != 0)X.pb(lw[c]);
			if(rw[c] != n+1)X.pb(rw[c]);
		}
		else {
			if(le[c] != 0)X.pb(le[c]);
			if(re[c] != n+1)X.pb(re[c]);
		}
		Y.pb(b); Y.pb(d);
		if(t[b-1] == 'S'){
			if(ln[b] != 0)Y.pb(ln[b]);
			if(rn[b] != m+1)Y.pb(rn[b]);
		}
		else {
			if(ls[b] != 0)Y.pb(ls[b]);
			if(rs[b] != m+1)Y.pb(rs[b]);
		}
		if(t[d-1] == 'S'){
			if(ln[d] != 0)Y.pb(ln[d]);
			if(rn[d] != m+1)Y.pb(rn[d]);
		}
		else {
			if(ls[d] != 0)Y.pb(ls[d]);
			if(rs[d] != m+1)Y.pb(rs[d]);
		}
		sor(X); uniq(X);
		sor(Y); uniq(Y);
		
		/*cout << "X:";
		for(int i: X)cout << i << " ";
		cout << endl;
		cout << "Y:";
		for(int i: Y)cout << i << " ";
		cout << endl;*/
		
		int _a = lower_bound(X.begin(),X.end(),a)-X.begin();
		int _b = lower_bound(Y.begin(),Y.end(),b)-Y.begin();
		int _c = lower_bound(X.begin(),X.end(),c)-X.begin();
		int _d = lower_bound(Y.begin(),Y.end(),d)-Y.begin();
		G.init(X.size()*Y.size());
		rep(i,X.size())rep(j,Y.size())for(int k = j+1 ; k < Y.size() ; k ++){
			if(s[X[i]-1] == 'W')G.add_edge(i*Y.size()+k,i*Y.size()+j,Y[k]-Y[j]);
			else G.add_edge(i*Y.size()+j,i*Y.size()+k,Y[k]-Y[j]);
		}
		rep(i,X.size())for(int j = i+1 ; j < X.size() ; j ++)rep(k,Y.size()){
			if(t[Y[k]-1] == 'N')G.add_edge(j*Y.size()+k,i*Y.size()+k,X[j]-X[i]);
			else G.add_edge(i*Y.size()+k,j*Y.size()+k,X[j]-X[i]);
		}
		int ret = G.dijkstra(_a*Y.size()+_b,_c*Y.size()+_d);
		if(ret >= INF)puts("-1");
		else printf("%d\n",ret);
		//printf("%d\n",G.dijkstra(_a*Y.size()+_b,_c*Y.size()+_d));
	}
}

Measured memory_bytes: 4864