#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((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})
          for(int nx:{pnu[xx],psu[xx]})
            if(nx<=x) push(y,nx,step+1,sum+abs(nx-x));      
      }else{
        for(int xx:{x,d})
          for(int nx:{pnl[xx],psl[xx]})
            if(nx>=x) push(y,nx,step+1,sum+abs(nx-x));      
      }
      if(t[x]=='N'){
        for(int yy:{y,c})
          for(int ny:{pwu[yy],peu[yy]})
            if(ny<=y) push(ny,x,step+1,sum+abs(ny-y));
      }else{        
        for(int yy:{y,c})
          for(int ny:{pwl[yy],pel[yy]})
            if(ny>=y) push(ny,x,step+1,sum+abs(ny-y));
      } 
    }
    if(ans==INF) ans=-1;
    cout<<ans<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 5900