#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int INF = INT_MAX / 4;

int selectSmall(const set<int>& s, int a)
{
    auto it = s.upper_bound(a);
    if(it == s.begin())
        return -INF;
    -- it;
    return *it;
}

int selectLarge(const set<int>& s, int a)
{
    auto it = s.lower_bound(a);
    if(it == s.end())
        return INF;
    return *it;
}

int solve(
    const set<int>& leftRoad,
    const set<int>& rightRoad,
    const set<int>& upRoad,
    const set<int>& downRoad,
    int sy, int sx, int gy, int gx, int depth
)
{
    if(sy == gy){
        if((leftRoad.find(sy) != leftRoad.end()) ^ (sx < gx))
            return abs(sx - gx);
    }

    if(depth == 0)
        return INF;

    int ans = INF;
    if(leftRoad.find(sy) != leftRoad.end()){
        int x1 = selectSmall(upRoad, sx);
        int x2 = selectSmall(downRoad, sx);
        if(x1 != sx)
            ans = min(ans, abs(sx - x1) + solve(upRoad, downRoad, leftRoad, rightRoad, x1, sy, gx, gy, depth - 1));
        if(x2 != sx)
            ans = min(ans, abs(sx - x2) + solve(upRoad, downRoad, leftRoad, rightRoad, x2, sy, gx, gy, depth - 1));
        if(gx < sx){
            int x3 = selectSmall(upRoad, gx);
            int x4 = selectSmall(downRoad, gx);
            ans = min(ans, abs(sx - x3) + solve(upRoad, downRoad, leftRoad, rightRoad, x3, sy, gx, gy, depth - 1));
            ans = min(ans, abs(sx - x4) + solve(upRoad, downRoad, leftRoad, rightRoad, x4, sy, gx, gy, depth - 1));
        }
    }
    else{
        int x1 = selectLarge(upRoad, sx);
        int x2 = selectLarge(downRoad, sx);
        if(x1 != sx)
            ans = min(ans, abs(sx - x1) + solve(upRoad, downRoad, leftRoad, rightRoad, x1, sy, gx, gy, depth - 1));
        if(x2 != sx)
            ans = min(ans, abs(sx - x2) + solve(upRoad, downRoad, leftRoad, rightRoad, x2, sy, gx, gy, depth - 1));
        if(sx < gx){
            int x3 = selectLarge(upRoad, gx);
            int x4 = selectLarge(downRoad, gx);
        ans = min(ans, abs(sx - x3) + solve(upRoad, downRoad, leftRoad, rightRoad, x3, sy, gx, gy, depth - 1));
        ans = min(ans, abs(sx - x4) + solve(upRoad, downRoad, leftRoad, rightRoad, x4, sy, gx, gy, depth - 1));
        }
    }
    return ans;
}

int main()
{
    int h, w, q;
    cin >> h >> w >> q;
    string s, t;
    cin >> s >> t;

    set<int> leftRoad, rightRoad, upRoad, downRoad;
    for(int y=0; y<h; ++y){
        if(s[y] == 'W')
            leftRoad.insert(y+1);
        else
            rightRoad.insert(y+1);
    }
    for(int x=0; x<w; ++x){
        if(t[x] == 'N')
            upRoad.insert(x+1);
        else
            downRoad.insert(x+1);
    }

    while(--q >= 0){
        int sy, sx, gy, gx;
        cin >> sy >> sx >> gy >> gx;
        int ans = min(solve(leftRoad, rightRoad, upRoad, downRoad, sy, sx, gy, gx, 4),
                      solve(upRoad, downRoad, leftRoad, rightRoad, sx, sy, gx, gy, 4));
        if(ans < INF)
            cout << ans << endl;
        else
            cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 12160