/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10, D = 5;
const int inf = 1e9 + 42;

int n, m;
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
int dir_x[N], dir_y[N];
int pref_x[N][D], pref_y[N][D];
int suff_x[N][D], suff_y[N][D];
vector<int> temp;

ll solve(int sx, int sy, int tx, int ty, int di);
inline bool can_move(int x, int y, int d);
inline bool on_path(int sx, int sy, int tx, int ty, int d);
inline ll get_dist(int sx, int sy, int tx, int ty);
inline bool in_dir(int sx, int sy, int tx, int ty, int d);
inline ll get_next_after(int &sx, int &sy, int tx, int ty, int d0, int d1);

int main() {
	fast_cin();
	int q; string s, t;
	cin >> n >> m >> q >> s >> t;
	for (int x = 1; x <= n; ++x) {
		dir_x[x] = ((s[x - 1] == 'E') ? 0 : 2);
		for (int d = 0; d < 4; ++d) {
			pref_x[x][d] = pref_x[x - 1][d];
		}
		pref_x[x][dir_x[x]] = x;
	}
	suff_x[n + 1][0] = suff_x[n + 1][1] = n + 1;
	for (int x = n; x >= 1; --x) {
		for (int d = 0; d < 4; ++d) {
			suff_x[x][d] = suff_x[x + 1][d];
		}
		suff_x[x][dir_x[x]] = x;
	}
	for (int y = 1; y <= m; ++y) {
		dir_y[y] = ((t[y - 1] == 'S') ? 3 : 1);
		for (int d = 0; d < 4; ++d) {
			pref_y[y][d] = pref_y[y - 1][d];
		}
		pref_y[y][dir_y[y]] = y;
	}
	suff_y[m + 1][0] = suff_y[m + 1][1] = m + 1;
	for (int y = m; y >= 1; --y) {
		for (int d = 0; d < 4; ++d) {
			suff_y[y][d] = suff_y[y + 1][d];
		}
		suff_y[y][dir_y[y]] = y;
	}
	while (q--) {
		int sx, sy, tx, ty;
		cin >> sx >> sy >> tx >> ty;
		ll ans = inf;
		for (int d0 = 0; d0 < 4; ++d0) {
			for (int d1 = 0; d1 < 4; ++d1) {
				if (d0 % 2 == d1 % 2) {
					continue;
				}
				for (int d2 = 0; d2 < 4; ++d2) {
					if (d1 % 2 == d2 % 2) {
						continue;
					}
					for (int d3 = 0; d3 < 4; ++d3) {
						if (d2 % 2 == d3 % 2) {
							continue;
						}
						for (int d4 = 0; d4 < 4; ++d4) {
							if (d3 % 2 == d4 % 2) {
								continue;
							}
							temp = {d0, d1, d2, d3, d4};
							ans = min(ans, solve(sx, sy, tx, ty, 4));
						}
					}
				}
			}
		}
		if (ans >= inf) {
			ans = -1;
		}
		cout << ans << '\n';
	}
}

ll solve(int sx, int sy, int tx, int ty, int di) {
	if (sx == tx and sy == ty) {
		return 0;
	} else if (di < 0) {
		return inf;
	} else if (!can_move(sx, sy, temp[di])) {
		return inf;
	} else {
		int d = temp[di];
		if (on_path(sx, sy, tx, ty, d)) {
			return get_dist(sx, sy, tx, ty);
		} else if (di == 0) {
			return inf;
		}
		int x = sx, y = sy;
		ll ans = get_next_after(x, y, sx, sy, d, temp[di - 1]);
		ans += solve(x, y, tx, ty, di - 1);
		if (in_dir(sx, sy, tx, ty, d)) {
			ll cand = get_next_after(sx, sy, tx, ty, d, temp[di - 1]);
			cand += solve(sx, sy, tx, ty, di - 1);
			ans = min(ans, cand);
		}
		return ans;
	}
}

inline bool can_move(int x, int y, int d) {
	if (d == 0 or d == 2) {
		return dir_x[x] == d;
	} else {
		return dir_y[y] == d;
	}
}

inline bool on_path(int sx, int sy, int tx, int ty, int d) {
	ll dist = get_dist(sx, sy, tx, ty);
	if (sx + dx[d] * dist == tx and sy + dy[d] * dist == ty) {
		return true;
	} else {
		return false;
	}
}

inline ll get_dist(int sx, int sy, int tx, int ty) {
	return abs(sx - tx) + abs(sy - ty);
}

inline bool in_dir(int sx, int sy, int tx, int ty, int d) {
	ll d1 = get_dist(sx, sy, tx, ty);
	ll d2 = get_dist(sx + dx[d], sy + dy[d], tx, ty);
	return d2 < d1;
}

inline ll get_next_after(int &sx, int &sy, int tx, int ty, int d0, int d1) {
	int x = sx, y = sy;
	if (d0 == 0) {
		y = suff_y[ty][d1];
	} else if (d0 == 1) {
		x = pref_x[tx][d1];
	} else if (d0 == 2) {
		y = pref_y[ty][d1];
	} else {
		x = suff_x[tx][d1];
	}
	if (x < 1 or x > n or y < 1 or y > m) {
		return inf;
	} else {
		ll ans = get_dist(x, y, sx, sy);
		sx = x; sy = y;
		return ans;
	}
}

Measured memory_bytes: 10448