#include <bits/stdc++.h>

using namespace std;

#define x1 qwe
#define y1 qwer
#define x2 qwert
#define y2 qwerty

const int max_n = 100111, inf = 1000111222;
const int max_v = 12;

int n, m, qu, dist[max_v][max_v];
char s[max_n], t[max_n];
vector<int> allx, ally;
vector<int> all_w, all_e, all_n, all_s;

void build(vector<int> &all, int x1, int x2, const vector<int> &a, const vector<int> &b) {
    all.clear();
    if (x1 > x2) {
        swap(x1, x2);
    }
    vector<int> v{-inf, x1, x2, inf};
    for (int i = 0; i + 1 < v.size(); ++i) {
        auto it = lower_bound(a.begin(), a.end(), v[i]);
        if (it != a.end()) {
            all.push_back(*it);
        }
        it = lower_bound(a.begin(), a.end(), v[i + 1]);
        if (it != a.begin()) {
            --it;
            all.push_back(*it);
        }

        it = lower_bound(b.begin(), b.end(), v[i]);
        if (it != b.end()) {
            all.push_back(*it);
        }
        it = lower_bound(b.begin(), b.end(), v[i + 1]);
        if (it != b.begin()) {
            --it;
            all.push_back(*it);
        }
    }
    sort(all.begin(), all.end());
    all.erase(unique(all.begin(), all.end()), all.end());
    assert(all.size() <= 12);
}

void build_graph(int x1, int y1, int x2, int y2) {
    build(allx, x1, x2, all_w, all_e);
    build(ally, y1, y2, all_n, all_s);
}

priority_queue<pair<int, pair<int, int>>> q;

void upd(int nx, int ny, int x, int y) {
    if (dist[nx][ny] > dist[x][y] + abs(allx[x] - allx[nx]) + abs(ally[y] - ally[ny])) {
        dist[nx][ny] = dist[x][y] + abs(allx[x] - allx[nx]) + abs(ally[y] - ally[ny]);
        q.push({-dist[nx][ny], {nx, ny}});
    }
}

void dijkstra(int sx, int sy) {
    for (int i = 0; i < allx.size(); ++i) {
        for (int j = 0; j < ally.size(); ++j) {
            dist[i][j] = inf;
        }
    }
    dist[sx][sy] = 0;
    q.push({0, {sx, sy}});
    while (!q.empty()) {
        auto p = q.top();
        q.pop();
        int x = p.second.first;
        int y = p.second.second;
        if (p.first != -dist[x][y]) {
            continue;
        }

        if (x && t[ally[y]] == 'N') {
            upd(x - 1, y, x, y);
        }
        if (x + 1 < allx.size() && t[ally[y]] == 'S') {
            upd(x + 1, y, x, y);
        }

        if (y && s[allx[x]] == 'W') {
            upd(x, y - 1, x, y);
        }
        if (y + 1 < ally.size() && s[allx[x]] == 'E') {
            upd(x, y + 1, x, y);
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d%s%s", &n, &m, &qu, s, t);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'E') {
            all_e.push_back(i);
        } else {
            all_w.push_back(i);
        }
    }
    for (int i = 0; i < m; ++i) {
        if (t[i] == 'N') {
            all_n.push_back(i);
        } else {
            all_s.push_back(i);
        }
    }
    while (qu--) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        --x1;
        --y1;
        --x2;
        --y2;
        build_graph(x1, y1, x2, y2);
        int sx, sy, fx, fy;
        for (int i = 0; i < allx.size(); ++i) {
            if (allx[i] == x1) {
                sx = i;
            }
            if (allx[i] == x2) {
                fx = i;
            }
        }
        for (int i = 0; i < ally.size(); ++i) {
            if (ally[i] == y1) {
                sy = i;
            }
            if (ally[i] == y2) {
                fy = i;
            }
        }
        dijkstra(sx, sy);
        if (dist[fx][fy] == inf) {
            puts("-1");
        } else {
            printf("%d\n", dist[fx][fy]);
        }
    }
    return 0;
}


Measured memory_bytes: 2768