output_description: In the i-th line, print the response to the i-th query. If the intersection
  (c_i, d_i) cannot be reached from the intersection (a_i, b_i) by walking along
  the roads, print `-1` instead.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M Q
      S
      T
      a_1 b_1 c_1 d_1
      a_2 b_2 c_2 d_2
      :
      a_Q b_Q c_Q d_Q
attempt: def read():
      N, M, Q = map(int, input().split(" "))
      S = input()
      T = input()
      qs = []
      for _ in range(N):
          a, b, c, d = map(int, input().split(" "))
          qs.append((a, b, c, d))
      return N, M, Q, S, T, qs
  
  
  DS = {"W": (-1, 0), "E": (1, 0), "N": (0, -1), "S": (0, 1)}
  
  
  def ans_q(N, M, Q, S, T, a, b, c, d):
      # ds[i][j] スタート地点からの距離(未達は-1)
      ds = [[-1 for _ in range(M)] for _ in range(N)]
      q = [(a - 1, b - 1)]
      ds[a - 1][b - 1] = 0
      while q:
          i, j = q.pop()
          dd = ds[i][j]
          drs = [DS.get(s) for s in [S[i], T[j]]]
          for dx, dy in drs:
              i2 = i + dy
              j2 = j + dx
              if i2 < 0 or i2 >= N or j2 < 0 or j2 >= M:
                  continue
              if ds[i2][j2] >= 0 and ds[i2][j2] <= dd + 1:
                  continue
              ds[i2][j2] = dd + 1
              q.append((i2, j2))
      return ds[c - 1][d - 1]
  
  
  if __name__ == "__main__":
      N, M, Q, S, T, qs = read()
      for a, b, c, d in qs:
          print(ans_q(N, M, Q, S, T, a, b, c, d))
  
problem_description: Statement
  
  In Takaha-shi, the capital of Republic of AtCoder, there are N roads extending
  east and west, and M roads extending north and south. There are no other
  roads. The i-th east-west road from the north and the j-th north-south road
  from the west cross at the intersection (i, j). Two east-west roads do not
  cross, nor do two north-south roads. The distance between two adjacent roads
  in the same direction is 1.
  
  Each road is one-way; one can only walk in one direction. The permitted
  direction for each road is described by a string S of length N and a string T
  of length M, as follows:
  
    * If the i-th character in S is `W`, one can only walk westward along the i-th east-west road from the north;
    * If the i-th character in S is `E`, one can only walk eastward along the i-th east-west road from the north;
    * If the i-th character in T is `N`, one can only walk northward along the i-th north-south road from the west;
    * If the i-th character in T is `S`, one can only walk southward along the i-th south-west road from the west.
  
  Process the following Q queries:
  
    * In the i-th query, a_i, b_i, c_i and d_i are given. What is the minimum distance to travel to reach the intersection (c_i, d_i) from the intersection (a_i, b_i) by walking along the roads?
samples: [{"input": "4 5 4\n    EEWW\n    NSNNS\n    4 1 1 4\n    1 3 1 2\n    4 2 3 2\n    3 3 3 5", "output": "6\n    11\n    5\n    4\n    \n\nThe permitted direction for each road is shown in the following figure (north\nupward):\n\n![](https://img.atcoder.jp/exawizards2019/bfb8c54cc4098353946320d8c263807e.png)\n\nFor each of the four queries, a route that achieves the minimum travel\ndistance is as follows:\n\n![](https://img.atcoder.jp/exawizards2019/d1918596004a23a20aa138e591e0ee99.png)\n\n* * *"}, {"input": "3 3 2\n    EEE\n    SSS\n    1 1 3 3\n    3 3 1 1", "output": "4\n    -1\n    \n\nThe travel may be impossible.\n\n* * *"}, {"input": "9 7 10\n    EEEEEWEWW\n    NSSSNSN\n    4 6 9 2\n    3 7 6 7\n    7 5 3 5\n    1 1 8 1\n    4 3 5 4\n    7 4 6 4\n    2 5 8 6\n    6 6 2 7\n    2 4 7 5\n    7 2 9 7", "output": "9\n    -1\n    4\n    9\n    2\n    3\n    7\n    7\n    6\n    -1"}]