Problem: Imagine an n × m grid with some blocked cells. The top left cell in the grid has coordinates (1, 1) and the bottom right cell has coordinates (n, m). There are k blocked cells in the grid and others are empty. You flash a laser beam from the center of an empty cell (xs, ys) in one of the diagonal directions (i.e. north-east, north-west, south-east or south-west). If the beam hits a blocked cell or the border of the grid it will reflect. The behavior of the beam reflection in different situations is depicted in the figure below. 

<image>

After a while the beam enters an infinite cycle. Count the number of empty cells that the beam goes through at least once. We consider that the beam goes through cell if it goes through its center.

Input

The first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 105, 0 ≤ k ≤ 105). Each of the next k lines contains two integers xi and yi (1 ≤ xi ≤ n, 1 ≤ yi ≤ m) indicating the position of the i-th blocked cell. 

The last line contains xs, ys (1 ≤ xs ≤ n, 1 ≤ ys ≤ m) and the flash direction which is equal to "NE", "NW", "SE" or "SW". These strings denote directions ( - 1, 1), ( - 1, - 1), (1, 1), (1, - 1).

It's guaranteed that no two blocked cells have the same coordinates.

Output

In the only line of the output print the number of empty cells that the beam goes through at least once.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3 3 0
1 2 SW


Output

6


Input

7 5 3
3 3
4 3
5 3
2 1 SE


Output

14

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct Trair {
  int x, y, z;
  Trair() {
    x = 0;
    y = 0;
    z = 0;
  }
  Trair(int _, int __, int ___) {
    x = _;
    y = __;
    z = ___;
  }
};
bool operator<(const Trair &A, const Trair &B) {
  if (A.x == B.x) {
    if (A.y == B.y) {
      return A.z < B.z;
    } else {
      return A.y < B.y;
    }
  } else {
    return A.x < B.x;
  }
}
bool operator<(const pair<int, int> &A, const pair<int, int> &B) {
  return A.first == B.first ? A.second > B.second : A.first < B.first;
}
set<pair<int, int> > Sa[100010 << 1];
set<pair<int, int> > Sb[100010 << 1];
set<pair<int, int> > ansA[100010 << 1];
set<pair<int, int> > ansB[100010 << 1];
set<pair<int, int> > obs;
set<Trair> vis;
int n, m, k;
int nextDirection(int x, int y, int d) {
  bool A, B;
  if (d == 0) {
    A = (obs.find(pair<int, int>(x, y - 1)) != obs.end());
    B = (obs.find(pair<int, int>(x + 1, y)) != obs.end());
    if (!A && !B) return 3;
    if (!A && B) return 1;
    if (A && !B) return 2;
    if (A && B) return 3;
  }
  if (d == 1) {
    A = (obs.find(pair<int, int>(x, y + 1)) != obs.end());
    B = (obs.find(pair<int, int>(x + 1, y)) != obs.end());
    if (!A && !B) return 2;
    if (!A && B) return 0;
    if (A && !B) return 3;
    if (A && B) return 2;
  }
  if (d == 2) {
    A = (obs.find(pair<int, int>(x, y - 1)) != obs.end());
    B = (obs.find(pair<int, int>(x - 1, y)) != obs.end());
    if (!A && !B) return 1;
    if (!A && B) return 3;
    if (A && !B) return 0;
    if (A && B) return 1;
  }
  if (d == 3) {
    A = (obs.find(pair<int, int>(x, y + 1)) != obs.end());
    B = (obs.find(pair<int, int>(x - 1, y)) != obs.end());
    if (!A && !B) return 0;
    if (!A && B) return 2;
    if (A && !B) return 1;
    if (A && B) return 0;
  }
}
int getOrderA(int x, int y) { return x + y; }
int getOrderB(int x, int y) { return x - y + m + 1; }
void insertObstacle(int x, int y) {
  obs.insert(pair<int, int>(x, y));
  Sa[getOrderA(x, y)].insert(pair<int, int>(x, y));
  Sb[getOrderB(x, y)].insert(pair<int, int>(x, y));
}
void nextObstacle(int x, int y, int d, int &ansx, int &ansy) {
  int ord;
  if (d == 0) {
    ord = getOrderA(x, y);
    Sa[ord].insert(pair<int, int>(x, y));
    set<pair<int, int> >::iterator p = Sa[ord].find(pair<int, int>(x, y));
    p--;
    ansx = (*p).first;
    ansy = (*p).second;
    Sa[ord].erase(pair<int, int>(x, y));
  }
  if (d == 1) {
    ord = getOrderB(x, y);
    Sb[ord].insert(pair<int, int>(x, y));
    set<pair<int, int> >::iterator p = Sb[ord].find(pair<int, int>(x, y));
    p--;
    ansx = (*p).first;
    ansy = (*p).second;
    Sb[ord].erase(pair<int, int>(x, y));
  }
  if (d == 2) {
    ord = getOrderB(x, y);
    Sb[ord].insert(pair<int, int>(x, y));
    set<pair<int, int> >::iterator p = Sb[ord].find(pair<int, int>(x, y));
    p++;
    ansx = (*p).first;
    ansy = (*p).second;
    Sb[ord].erase(pair<int, int>(x, y));
  }
  if (d == 3) {
    ord = getOrderA(x, y);
    Sa[ord].insert(pair<int, int>(x, y));
    set<pair<int, int> >::iterator p = Sa[ord].find(pair<int, int>(x, y));
    p++;
    ansx = (*p).first;
    ansy = (*p).second;
    Sa[ord].erase(pair<int, int>(x, y));
  }
}
void insertAns(int x, int y, int d, int nxty) {
  int ord;
  if (d == 0) {
    ord = getOrderA(x, y);
    ansA[ord].insert(pair<int, int>(y, nxty - 1));
  }
  if (d == 1) {
    ord = getOrderB(x, y);
    ansB[ord].insert(pair<int, int>(nxty + 1, y));
  }
  if (d == 2) {
    ord = getOrderB(x, y);
    ansB[ord].insert(pair<int, int>(y, nxty - 1));
  }
  if (d == 3) {
    ord = getOrderA(x, y);
    ansA[ord].insert(pair<int, int>(nxty + 1, y));
  }
}
void nextStart(int nxtx, int nxty, int nxtd, int &x, int &y, int &d) {
  if ((d & 1) != (nxtd & 1) && (d & 2) != (nxtd & 2)) {
    d = nxtd;
    return;
  }
  x = nxtx;
  y = nxty;
  if (nxtd == 0) {
    if ((d & 1) == (nxtd & 1)) x = nxtx - 1;
    if ((d & 2) == (nxtd & 2)) y = nxty + 1;
  }
  if (nxtd == 1) {
    if ((d & 1) == (nxtd & 1)) x = nxtx - 1;
    if ((d & 2) == (nxtd & 2)) y = nxty - 1;
  }
  if (nxtd == 2) {
    if ((d & 1) == (nxtd & 1)) x = nxtx + 1;
    if ((d & 2) == (nxtd & 2)) y = nxty + 1;
  }
  if (nxtd == 3) {
    if ((d & 1) == (nxtd & 1)) x = nxtx + 1;
    if ((d & 2) == (nxtd & 2)) y = nxty - 1;
  }
  d = nxtd;
}
int getAns(set<pair<int, int> > S) {
  int last = 0, ret = 0;
  for (set<pair<int, int> >::iterator it = S.begin(); it != S.end(); it++) {
    if ((*it).first > last) {
      ret += ((*it).second - (*it).first + 1);
      last = (*it).second;
    } else if ((*it).second > last) {
      ret += ((*it).second - last);
      last = (*it).second;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    insertObstacle(x, y);
  }
  for (int i = 0; i <= n + 1; i++) {
    insertObstacle(i, 0);
    insertObstacle(i, m + 1);
  }
  for (int i = 0; i <= m + 1; i++) {
    insertObstacle(0, i);
    insertObstacle(n + 1, i);
  }
  int nowx, nowy, nowd = 0;
  char dir[5];
  scanf("%d%d%s", &nowx, &nowy, dir);
  if (dir[0] == 'S') nowd += 2;
  if (dir[1] == 'W') nowd += 1;
  while (true) {
    int nxtx, nxty, nxtd;
    nextObstacle(nowx, nowy, nowd, nxtx, nxty);
    insertAns(nowx, nowy, nowd, nxty);
    if (vis.find(Trair(nxtx, nxty, nowd)) != vis.end()) {
      break;
    }
    vis.insert(Trair(nxtx, nxty, nowd));
    nxtd = nextDirection(nxtx, nxty, nowd);
    nextStart(nxtx, nxty, nxtd, nowx, nowy, nowd);
  }
  long long ans = 0;
  for (int i = 0; i <= n + m + 2; i++) {
    ans += abs(getAns(ansA[i]));
  }
  for (int i = 0; i <= n + m + 2; i++) {
    ans += abs(getAns(ansB[i]));
  }
  printf("%lld\n", ans);
  return 0;
}