#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i, a, n) for(LL i = (a), i##_max = (n); i < i##_max; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##min = (a); i >= i##min; --i)
#define ALL(arr) (arr).begin(), (arr).end()
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class T>
T Next() { T buf; cin >> buf; return buf; }

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "BinaryMatrix.h"
#include "BIT.h"
#include "Factorization.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "LazySegmentTree.h"
#include "Math.h"
#include "Matrix.h"
#include "MinMax.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "SuffixArray.h"
#include "Tree.h"
#include "UnionFind.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
// template <class T>
// auto Is(const T& value) { return [value](const auto& comparand) -> bool { return comparand == value; }; }
#endif

int H, W;
vector<int> S;
vector<int> T;
int P[4][100000];
int Q[4][100000];

const int di[] = { -1, 0, 1, 0 };
const int dj[] = { 0, -1, 0, 1 };
const int BIG = 1e8;

int rec(int n, int dir, int i, int j, int gi, int gj, int h, int w) {
	if (i < 0 || i > h) return BIG;
	if (j < 0 || j > w) return BIG;
	int ri = gi - i;
	int rj = gj - j;
	if (ri <= 0 && rj == 0) return -ri;
	if (n == 0) return BIG;

	if (ri < 0) {
		if (rj < 0) {
			int lfront = h - Q[(dir + 2) % 4][h - gi];
			int lback = P[dir][gi];
			int rfront = Q[dir][i];

			int mn = BIG;
			if (lfront <= i) 
			mn = min(mn, rec(n - 1, (dir + 1) % 4, j, h - lfront, gj, h - gi, w, h) + i - lfront);
			mn = min(mn, rec(n - 1, (dir + 1) % 4, j, h - lback, gj, h - gi, w, h) + i - lback);
			mn = min(mn, rec(n - 1, (dir + 3) % 4, w - j, rfront, w - gj, gi, w, h) + i - rfront);
			return mn;
		} else {
			int rfront = h - P[(dir + 2) % 4][h - gi];
			int rback = Q[dir][gi];
			int lfront = P[dir][i];

			int mn = BIG;
			if (rfront <= i) 
			mn = min(mn, rec(n - 1, (dir + 3) % 4, w - j, rfront, w - gj, gi, w, h) + i - rfront);
			mn = min(mn, rec(n - 1, (dir + 3) % 4, w - j, rback, w - gj, gi, w, h) + i - rback);
			mn = min(mn, rec(n - 1, (dir + 1) % 4, j, h - lfront, gj, h - gi, w, h) + i - lfront);
			return mn;
		}
	} else {
		int lfront = P[dir][i];
		int rfront = Q[dir][i];

		int mn = BIG;
		mn = min(mn, rec(n - 1, (dir + 1) % 4, j, h - lfront, gj, h - gi, w, h) + i - lfront);
		mn = min(mn, rec(n - 1, (dir + 3) % 4, w - j, rfront, w - gj, gi, w, h) + i - rfront);
		return mn;
	}
}

int sub(int si, int sj, int gi, int gj) {
	int mn = BIG;
	if (T[sj] == 0) {
		mn = min(mn, rec(4, 0, si, sj, gi, gj, H, W));
	} else {
		mn = min(mn, rec(4, 2, H - si, W - sj, H - gi, W - gj, H, W));
	}

	if (S[si] == 0) {
		mn = min(mn, rec(4, 1, sj, H - si, gj, H - gi, W, H));
	} else {
		mn = min(mn, rec(4, 3, W - sj, si, W - gj, gi, W, H));
	}
	return mn;
}

void pre() {
	{
		int l = -BIG;
		int r = -BIG;
		REP(i, 0, H + 1) {
			if (!S[i]) l = i;
			if (S[i]) r = i;
			P[0][i] = l;
			Q[0][i] = r;
		}
	}

	{
		int l = -BIG;
		int r = -BIG;
		REP(j, 0, W + 1) {
			if (T[j]) l = j;
			if (!T[j]) r = j;
			P[1][j] = l;
			Q[1][j] = r;
		}
	}
	
	{
		int l = -BIG;
		int r = -BIG;
		REP(i, 0, H + 1) {
			if (S[H - i]) l = i;
			if (!S[H - i]) r = i;
			P[2][i] = l;
			Q[2][i] = r;
		}
	}

	{
		int l = -BIG;
		int r = -BIG;
		REP(j, 0, W + 1) {
			if (!T[W - j]) l = j;
			if (T[W - j]) r = j;
			P[3][j] = l;
			Q[3][j] = r;
		}
	}
}

int main() {
	int Q;
	string s, t;
	vector<PP> A;
	vector<PP> B;

	cin >> H >> W >> Q;
	--H; --W;
	cin >> s >> t;
	for (char c : s) S.push_back(c == 'E');
	for (char c : t) T.push_back(c == 'S');

	pre();

	REP(i, 0, Q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a; --b; --c; --d;
		int ans = sub(a, b, c, d);
		cout << (ans >= BIG ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 5756