import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum INF = 10^^9;
enum L = 7;

int M, N, Q;
string S, T;
int[] A, B, C, D;

void main() {
  try {
    for (; ; ) {
      M = readInt();
      N = readInt();
      Q = readInt();
      S = readToken();
      T = readToken();
      A = new int[Q];
      B = new int[Q];
      C = new int[Q];
      D = new int[Q];
      foreach (q; 0 .. Q) {
        A[q] = readInt() - 1;
        B[q] = readInt() - 1;
        C[q] = readInt() - 1;
        D[q] = readInt() - 1;
      }
      
      auto nextE = new int[M];
      auto nextW = new int[M];
      auto prevE = new int[M];
      auto prevW = new int[M];
      auto nextS = new int[N];
      auto nextN = new int[N];
      auto prevS = new int[N];
      auto prevN = new int[N];
      foreach_reverse (x; 0 .. M) {
        nextE[x] = (S[x] == 'E') ? x : (x == M - 1) ? M : nextE[x + 1];
        nextW[x] = (S[x] == 'W') ? x : (x == M - 1) ? M : nextW[x + 1];
      }
      foreach (x; 0 .. M) {
        prevE[x] = (S[x] == 'E') ? x : (x == 0) ? -1 : prevE[x - 1];
        prevW[x] = (S[x] == 'W') ? x : (x == 0) ? -1 : prevW[x - 1];
      }
      foreach_reverse (y; 0 .. N) {
        nextS[y] = (T[y] == 'S') ? y : (y == N - 1) ? N : nextS[y + 1];
        nextN[y] = (T[y] == 'N') ? y : (y == N - 1) ? N : nextN[y + 1];
      }
      foreach (y; 0 .. N) {
        prevS[y] = (T[y] == 'S') ? y : (y == 0) ? -1 : prevS[y - 1];
        prevN[y] = (T[y] == 'N') ? y : (y == 0) ? -1 : prevN[y - 1];
      }
      debug {
        writeln("nextE = ", nextE);
        writeln("nextW = ", nextW);
        writeln("prevE = ", prevE);
        writeln("prevW = ", prevW);
        writeln("nextS = ", nextS);
        writeln("nextN = ", nextN);
        writeln("prevS = ", prevS);
        writeln("prevN = ", prevN);
      }
      
      foreach (q; 0 .. Q) {
        int ans = INF;
        foreach (dir; 0 .. 2) {
          foreach (p; 0 .. 1 << L) {
            int cost;
            int x = A[q], y = B[q];
            foreach (i; 0 .. L) {
              if (x == C[q] && y == D[q]) {
                chmin(ans, cost);
                break;
              }
              if ((dir + i) & 1) {
                // vertical move
                if (T[y] == 'S') {
                  int xx;
                  if ((p >> i) & 1) {
                    xx = (S[x] != 'E') ? nextE[x] : nextW[x];
                  } else {
                    if (x < C[q]) {
                      if (y == D[q]) {
                        chmin(ans, cost + (C[q] - x));
                        break;
                      }
                      xx = (y < D[q]) ? nextE[C[q]] : nextW[C[q]];
                    } else {
                      break;
                    }
                  }
                  if (xx >= M) {
                    break;
                  }
                  cost += (xx - x);
                  x = xx;
                } else {
                  int xx;
                  if ((p >> i) & 1) {
                    xx = (S[x] != 'E') ? prevE[x] : prevW[x];
                  } else {
                    if (x > C[q]) {
                      if (y == D[q]) {
                        chmin(ans, cost + (x - C[q]));
                        break;
                      }
                      xx = (y < D[q]) ? prevE[C[q]] : prevW[C[q]];
                    } else {
                      break;
                    }
                  }
                  if (xx < 0) {
                    break;
                  }
                  cost += (x - xx);
                  x = xx;
                }
              } else {
                // horizontal move
                if (S[x] == 'E') {
                  int yy;
                  if ((p >> i) & 1) {
                    yy = (T[y] != 'S') ? nextS[y] : nextN[y];
                  } else {
                    if (y < D[q]) {
                      if (x == C[q]) {
                        chmin(ans, cost + (D[q] - y));
                        break;
                      }
                      yy = (x < C[q]) ? nextS[D[q]] : nextN[D[q]];
                    } else {
                      break;
                    }
                  }
                  if (yy >= N) {
                    break;
                  }
                  cost += (yy - y);
                  y = yy;
                } else {
                  int yy;
                  if ((p >> i) & 1) {
                    yy = (T[y] != 'S') ? prevS[y] : prevN[y];
                  } else {
                    if (y > D[q]) {
                      if (x == C[q]) {
                        chmin(ans, cost + (y - D[q]));
                        break;
                      }
                      yy = (x < C[q]) ? prevS[D[q]] : prevN[D[q]];
                    } else {
                      break;
                    }
                  }
                  if (yy < 0) {
                    break;
                  }
                  cost += (y - yy);
                  y = yy;
                }
              }
            }
          }
        }
        writeln((ans < INF) ? ans : -1);
      }
      
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 12540