#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  string s,t;
  cin>>s>>t;
  
  const int INF = 1e9;
  vector<int> vw,ve,vn,vs;
  vw.emplace_back(-INF);
  ve.emplace_back(-INF);
  vn.emplace_back(-INF);
  vs.emplace_back(-INF);  
  for(int i=0;i<n;i++){
    if(s[i]=='W') vw.emplace_back(i);
    if(s[i]=='E') ve.emplace_back(i);
  }
  for(int i=0;i<m;i++){
    if(t[i]=='N') vn.emplace_back(i);
    if(t[i]=='S') vs.emplace_back(i);
  }  
  vw.emplace_back(+INF);
  ve.emplace_back(+INF);
  vn.emplace_back(+INF);
  vs.emplace_back(+INF);

  vector<int> pnu(m),psu(m);
  vector<int> pnl(m),psl(m);
  for(int j=0;j<m;j++){    
    pnu[j]=*--upper_bound(vn.begin(),vn.end(),j);
    psu[j]=*--upper_bound(vs.begin(),vs.end(),j);    
    pnl[j]=*lower_bound(vn.begin(),vn.end(),j);
    psl[j]=*lower_bound(vs.begin(),vs.end(),j);
  }
  
  vector<int> pwu(n),peu(n);
  vector<int> pwl(n),pel(n);
  for(int i=0;i<n;i++){    
    pwu[i]=*--upper_bound(vw.begin(),vw.end(),i);
    peu[i]=*--upper_bound(ve.begin(),ve.end(),i);    
    pwl[i]=*lower_bound(vw.begin(),vw.end(),i);
    pel[i]=*lower_bound(ve.begin(),ve.end(),i);
  }      
  
  for(int i=0;i<q;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;c--;d--;

    using ll = long long;    
    auto T=[&](int y,int x,int step){return ((ll)y<<40)|((ll)x<<20)|(ll)step;};
    map<ll, int> dp;
    using P = pair<int, ll>;
    priority_queue<P, vector<P>, greater<P> > pq;
    dp[T(a,b,0)]=0;
    pq.emplace(dp[T(a,b,0)],T(a,b,0));

    int ans=INF;
    while(!pq.empty()){
      int sum=pq.top().first;
      ll st=pq.top().second;
      pq.pop();
      if(dp[st]<sum) continue;
      int y,x,step;
      y=(st>>40);
      x=(st>>20)^((ll)y<<20);
      step=st&((1<<20)-1);
      
      if(sum+abs(y-c)+abs(x-d)>=ans) continue;
      
      if((s[y]=='E'&&x<=d)||(s[y]=='W'&&x>=d))
        if((t[d]=='S'&&y<=c)||(t[d]=='N'&&y>=c))
          chmin(ans,sum+abs(y-c)+abs(x-d));
      
      if((t[x]=='S'&&y<=c)||(t[x]=='N'&&y>=c))
        if((s[c]=='E'&&x<=d)||(s[c]=='W'&&x>=d))
          chmin(ans,sum+abs(y-c)+abs(x-d));

      if(sum+abs(y-c)+abs(x-d)>=ans) continue;
      if(step>=3) continue;
      auto push=
        [&](int ny,int nx,int ns,int nd){
          if(abs(ny)==INF||abs(nx)==INF) return;
          if(ny==y&&nx==x) return;         
          if(dp.find(T(ny,nx,ns))!=dp.end()&&dp[T(ny,nx,ns)]<=nd) return;
          if(nd+abs(ny-c)+abs(nx-d)>=ans) return;
          dp[T(ny,nx,ns)]=nd;
          pq.emplace(nd,T(ny,nx,ns));
        };

      if(s[y]=='W'){
        for(int xx:{x,d}){
          // N           
          if(pnu[xx]<=x)
            push(y,pnu[xx],step+1,sum+abs(pnu[xx]-x));
          // S
          if(psu[xx]<=x)
            push(y,psu[xx],step+1,sum+abs(psu[xx]-x));
        }
      }else{
        for(int xx:{x,d}){
          // N           
          if(pnl[xx]>=x)
            push(y,pnl[xx],step+1,sum+abs(pnl[xx]-x));
          // S
          if(psl[xx]>=x)
            push(y,psl[xx],step+1,sum+abs(psl[xx]-x));
        }
      }
      if(t[x]=='N'){
        for(int yy:{y,c}){
          // W
          if(pwu[yy]<=y)
            push(pwu[yy],x,step+1,sum+abs(pwu[yy]-y));
          // E
          if(peu[yy]<=y)
            push(peu[yy],x,step+1,sum+abs(peu[yy]-y));
        }
      }else{        
        for(int yy:{y,c}){
          // W
          if(pwl[yy]>=y)
            push(pwl[yy],x,step+1,sum+abs(pwl[yy]-y));
          // E
          if(pel[yy]>=y)
            push(pel[yy],x,step+1,sum+abs(pel[yy]-y));
        }
      } 
    }
    if(ans==INF) ans=-1;
    cout<<ans<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 5964