#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define inf 0x3f3f3f3f
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, M, Q, S, T, tope = 0; char s[100005], t[100005];
int UW[100005], UE[100005], DW[100005], DE[100005];
int LN[100005], LS[100005], RN[100005], RS[100005];
int R[10], C[10], topR, topC, id[10][10], cnt;
int dis[40], q[40], fr, re, inq[40];
struct Edge {int np, val; Edge *nxt;} E[65], *V[40];
#define tasu1(x) (x = x < 40 ? x + 1 : 0)

inline void addedge(const int &u, const int &v, const int &w){
	E[++tope].np = v, E[tope].val = w;
	E[tope].nxt = V[u], V[u] = E + tope;
	
//	printf("%d -> %d : %d\n", u, v, w);
}

inline int SPFA(){
	memset(dis, 0x3f, sizeof(int) * (cnt + 1));
	memset(inq, 0, sizeof(int) * (cnt + 1));
	dis[S] = 0, inq[q[0] = S] = 1, fr = 0, re = 1;
	while(fr != re){
		const int u = q[fr]; tasu1(fr), inq[u] = 0;
		for(register Edge *ne = V[u]; ne; ne = ne->nxt)
			if(dis[u] + ne->val < dis[ne->np]){
				dis[ne->np] = dis[u] + ne->val;
				if(!inq[ne->np]) q[re] = ne->np, tasu1(re), inq[ne->np] = 1;
			}
	}
	return dis[T] < inf ? dis[T] : -1;
}

int main(){
	getint(N), getint(M), getint(Q), scanf("%s%s", s + 1, t + 1);
	UW[0] = UE[0] = DW[N + 1] = DE[N + 1] = N + 1;
	LN[0] = LS[0] = RN[M + 1] = RS[M + 1] = M + 1;
	for(register int i = 1; i <= N; i++){
		UW[i] = s[i] == 'W' ? i : UW[i - 1];
		UE[i] = s[i] == 'E' ? i : UE[i - 1];
	}
	for(register int i = N; i >= 1; i--){
		DW[i] = s[i] == 'W' ? i : DW[i + 1];
		DE[i] = s[i] == 'E' ? i : DE[i + 1];
	}
	for(register int i = 1; i <= M; i++){
		LN[i] = t[i] == 'N' ? i : LN[i - 1];
		LS[i] = t[i] == 'S' ? i : LS[i - 1];
	}
	for(register int i = M; i >= 1; i--){
		RN[i] = t[i] == 'N' ? i : RN[i + 1];
		RS[i] = t[i] == 'S' ? i : RS[i + 1];
	}
	while(Q--){
		int a, b, c, d; getint(a), getint(b), getint(c), getint(d);
		R[1] = UW[a], R[2] = DW[a], R[3] = UW[c], R[4] = DW[c];
		R[5] = UE[a], R[6] = DE[a], R[7] = UE[c], R[8] = DE[c];
		C[1] = LN[b], C[2] = RN[b], C[3] = LN[d], C[4] = RN[d];
		C[5] = LS[b], C[6] = RS[b], C[7] = LS[d], C[8] = RS[d];
		sort(R + 1, R + 9), topR = unique(R + 1, R + 9) - R - 1;
		sort(C + 1, C + 9), topC = unique(C + 1, C + 9) - C - 1, cnt = 0;
		if(R[topR] > N) topR--; if(C[topC] > M) topC--;
		for(register int i = 1; i <= topR; i++)
			for(register int j = 1; j <= topC; j++){
				id[i][j] = ++cnt;
				if(R[i] == a && C[j] == b) S = cnt;
				if(R[i] == c && C[j] == d) T = cnt;
			}
		
//		puts("\n======= Intersect Debug hajimaru ======");
//		for(register int i = 1; i <= topR; i++) printf("(%d, %c) ", R[i], s[R[i]]); puts("");
//		for(register int i = 1; i <= topC; i++) printf("(%d, %c) ", C[i], t[C[i]]); puts("");
//		puts("========= Intersect Debug owaru =======\n");
//		
//		puts("\n========== ID Debug hajimaru ==========");
//		for(register int i = 1; i <= topR; i++, puts(""))
//			for(register int j = 1; j <= topC; j++)
//				printf("[%d](%d, %d) ", id[i][j], R[i], C[j]);
//		puts("=========== ID Debug owaru ===========\n");
//		
//		
//		puts("\n========== Edge Debug hajimaru =========");
		
		memset(V, 0, sizeof(Edge*) * (cnt + 1)), tope = 0;
		for(register int i = 1; i <= topR; i++)
			for(register int j = 1; j < topC; j++)
				if(s[R[i]] == 'W') addedge(id[i][j + 1], id[i][j], C[j + 1] - C[j]);
				else addedge(id[i][j], id[i][j + 1], C[j + 1] - C[j]);
		for(register int j = 1; j <= topC; j++)
			for(register int i = 1; i < topR; i++)
				if(t[C[j]] == 'N') addedge(id[i + 1][j], id[i][j], R[i + 1] - R[i]);
				else addedge(id[i][j], id[i + 1][j], R[i + 1] - R[i]);
		
//		puts("============ Edge Debug owaru ==========\n");
		
		printf("%d\n", SPFA());
	}
	return 0;
}

Measured memory_bytes: 4736