#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q;
    cin >> n >> m >> q;
    string s,t;
    cin >> s >> t;
    vector<int> L,R;
    vector<int> U,D;
    rep(i,n){
        if(s[i]=='W'){
            L.push_back(i);
        }else{
            R.push_back(i);
        }
    }
    rep(i,m){
        if(t[i]=='N'){
            U.push_back(i);
        }else{
            D.push_back(i);
        }
    }
    rep(zz,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;d--;
        queue<pair<pair<pair<int,int>,pair<int,int> >,pair<int,int> > >q;
        if(t[b]=='N'){
            q.push(MP(MP(MP(0,0),MP(a,b)),MP(-1,1)));
        }else{
            q.push(MP(MP(MP(0,0),MP(a,b)),MP(1,1)));
        }
        if(s[a]=='W'){
            q.push(MP(MP(MP(0,0),MP(a,b)),MP(-1,0)));
        }else{
            q.push(MP(MP(MP(0,0),MP(a,b)),MP(1,0)));
        }
        int mi = inf;
        while(!q.empty()){
            auto x = q.front();
            q.pop();
            int dist = x.first.first.first;
            int cnt = x.first.first.second;
            int na = x.first.second.first;
            int nb = x.first.second.second;
            int pl = x.second.first;
            int dir = x.second.second;
            // cerr << na << " " << nb << " " << dist << " " << cnt << " " << pl << " " << dir << endl;
            if(na==c&&nb==d){
                chmin(mi,dist);
                continue;
            }
            if(cnt==5)continue;
            if(dir==1){// UP DOWN
                if(pl==-1){//UP
                    if(c<na&&nb==d){
                        chmin(mi,dist+na-c);
                        continue;
                    }        
                    if(true||nb<=d){
                        int tar = min(na,c);
                        auto x = lower_bound(all(R),tar);
                        if(x!=R.end()){
                            int nna = *x;
                            if(nna<na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(1,0)));
                        }
                        if(x!=R.begin()){
                            x--;
                            int nna = *x;
                            if(nna<na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(1,0)));
                        }
                    }
                    if(true||nb>=d){
                        int tar = min(na,c);
                        auto x = lower_bound(all(L),tar);
                        if(x!=L.end()){
                            int nna = *x;
                            if(nna<na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(-1,0)));
                        }
                        if(x!=L.begin()){
                            x--;
                            int nna = *x;
                            if(nna<na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(-1,0)));
                        }
                    }
                }else{//DOWN
                    if(c>na&&nb==d){
                        chmin(mi,dist+abs(c-na));
                        continue;
                    }        
                    if(true||nb<=d){
                        int tar = max(na,c);
                        auto x = lower_bound(all(R),tar);
                        if(x!=R.end()){
                            int nna = *x;
                            if(nna>na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(1,0)));
                        }
                        if(x!=R.begin()){
                            x--;
                            int nna = *x;
                            if(nna>na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(1,0)));
                        }
                    }
                    if(true||nb>=d){
                        int tar = max(na,c);
                        auto x = lower_bound(all(L),tar);
                        if(x!=L.end()){
                            int nna = *x;
                            if(nna>na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(-1,0)));
                        }
                        if(x!=L.begin()){
                            x--;
                            int nna = *x;
                            if(nna>na)q.push(MP(MP(MP(dist+abs(nna-na),cnt+1),MP(nna,nb)),MP(-1,0)));
                        }
                    }
                }

            }else{// LEFT RIGHT
                if(pl==-1){//LEFT
                    if(d<nb&&na==c){
                        chmin(mi,dist+abs(nb-d));
                        continue;
                    }        
                    if(true||na<=c){
                        int tar = min(nb,d);
                        auto x = lower_bound(all(D),tar);
                        if(x!=D.end()){
                            int nnb = *x;
                            if(nnb<nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(1,1)));
                        }
                        if(x!=D.begin()){
                            x--;
                            int nnb = *x;
                            if(nnb<nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(1,1)));
                        }
                    }
                    if(true||na>=c){
                        int tar = min(nb,d);
                        auto x = lower_bound(all(U),tar);
                        if(x!=U.end()){
                            int nnb = *x;
                            if(nnb<nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(-1,1)));
                        }
                        if(x!=U.begin()){
                            x--;
                            int nnb = *x;
                            if(nnb<nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(-1,1)));
                        }
                    }
                }else{//RIGHT
                    if(d>nb&&na==c){
                        chmin(mi,dist+abs(d-nb));
                        continue;
                    }        
                    if(true||na<=c){
                        int tar = max(nb,d);
                        auto x = lower_bound(all(D),tar);
                        if(x!=D.end()){
                            int nnb = *x;
                            if(nnb>nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(1,1)));
                        }
                        if(x!=D.begin()){
                            x--;
                            int nnb = *x;
                            if(nnb>nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(1,1)));
                        }
                    }
                    if(true||na>=c){
                        int tar = max(nb,d);
                        auto x = lower_bound(all(U),tar);
                        if(x!=U.end()){
                            int nnb = *x;
                            if(nnb>nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(-1,1)));
                        }
                        if(x!=U.begin()){
                            x--;
                            int nnb = *x;
                            if(nnb>nb)q.push(MP(MP(MP(dist+abs(nnb-nb),cnt+1),MP(na,nnb)),MP(-1,1)));
                        }
                    }
                }
            }
        }
        if(mi!=inf){
            cout << mi << "\n";
        }else{
            cout << -1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4260