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;
map<pair<int, int>, int> tb;
class PT {
 public:
  int x, y, i;
  PT() {}
  PT(int _x, int _y) {
    x = _x + _y;
    y = _x - _y;
  }
};
PT pt[1000000];
int eg[1000000][4];
int pos[1000000][2];
int F, n, m;
bool cmpx(const PT& a, const PT& b) {
  if (a.x == b.x) {
    if (a.y == b.y) return a.i < b.i;
    return a.y < b.y;
  }
  return a.x < b.x;
}
bool cmpy(const PT& a, const PT& b) {
  if (a.y == b.y) {
    if (a.x == b.x) return a.i < b.i;
    return a.x < b.x;
  }
  return a.y < b.y;
}
bool cmp(const PT& a, const PT& b) { return a.i < b.i; }
inline int ABS(int x) { return x < 0 ? -x : x; }
inline int hit(int x, int y) {
  return x <= 0 || y <= 0 || x > n || y > m || tb[make_pair(x, y)];
}
int main() {
  int r, pn, x, y, i, j, k, sx, sy, sd, d, dx, dy, dd, f;
  long long sum;
  int a[4];
  char str[10];
  scanf("%d %d %d", &n, &m, &r);
  for (int i = 0; i < r; i++) {
    scanf("%d %d", &x, &y);
    tb[make_pair(x, y)] = 1;
  }
  scanf("%d %d %s", &sx, &sy, str);
  pn = 0;
  if (str[0] == 'S') {
    if (str[1] == 'E') {
      F = (sx + sy) % 2;
      pt[pn++] = PT(sx - 1, sy - 1);
      sd = 0;
    } else {
      F = (sx + sy + 1) % 2;
      pt[pn++] = PT(sx - 1, sy);
      sd = 1;
    }
  } else {
    if (str[1] == 'E') {
      F = (sx + sy + 1) % 2;
      pt[pn++] = PT(sx, sy - 1);
      sd = 3;
    } else {
      F = (sx + sy) % 2;
      pt[pn++] = PT(sx, sy);
      sd = 2;
    }
  }
  for (map<pair<int, int>, int>::iterator it = tb.begin(); it != tb.end();
       ++it) {
    x = it->first.first;
    y = it->first.second;
    if ((x + y) % 2 == F) {
      if (x != n && y != m) pt[pn++] = PT(x, y);
      if (x - 1 != 0 && y - 1 != 0) pt[pn++] = PT(x - 1, y - 1);
    } else {
      if (x - 1 != 0 && y != m) pt[pn++] = PT(x - 1, y);
      if (x != n && y - 1 != 0) pt[pn++] = PT(x, y - 1);
    }
  }
  for (x = 0; x <= n; x++) {
    if ((x + 0) % 2 == F) pt[pn++] = PT(x, 0);
    if ((x + m) % 2 == F) pt[pn++] = PT(x, m);
  }
  for (y = 1; y < m; y++) {
    if ((0 + y) % 2 == F) pt[pn++] = PT(0, y);
    if ((n + y) % 2 == F) pt[pn++] = PT(n, y);
  }
  for (i = 0; i < pn; i++) {
    pt[i].i = i;
    pos[i][0] = (pt[i].x + pt[i].y) / 2;
    pos[i][1] = (pt[i].x - pt[i].y) / 2;
  }
  memset(eg, -1, sizeof(eg));
  sort(pt, pt + pn, cmpx);
  for (i = 1, j = 0; i < pn; i++) {
    if (pt[i].x != pt[j].x || pt[i].y != pt[j].y) {
      pt[++j] = pt[i];
    }
  }
  pn = j + 1;
  pt[pn].x = 1000000000;
  pt[pn].y = 1000000000;
  for (i = 1, j = 0; i <= pn; i++) {
    if (pt[i].x != pt[i - 1].x) {
      for (j++; j < i; j++) {
        eg[pt[j - 1].i][1] = pt[j].i;
        eg[pt[j].i][3] = pt[j - 1].i;
      }
    }
  }
  sort(pt, pt + pn, cmpy);
  for (i = 1, j = 0; i <= pn; i++) {
    if (pt[i].y != pt[i - 1].y) {
      for (j++; j < i; j++) {
        eg[pt[j - 1].i][0] = pt[j].i;
        eg[pt[j].i][2] = pt[j - 1].i;
      }
    }
  }
  sort(pt, pt + pn, cmp);
  i = 0;
  d = sd;
  sum = 0;
  f = 0;
  while (1) {
    j = eg[i][d];
    sum += ABS(pos[j][0] - pos[i][0]) + ABS(pos[j][1] - pos[i][1]);
    a[0] = hit(pos[j][0] + 1, pos[j][1] + 1);
    a[1] = hit(pos[j][0] + 1, pos[j][1]);
    a[2] = hit(pos[j][0], pos[j][1]);
    a[3] = hit(pos[j][0], pos[j][1] + 1);
    if (a[d]) {
      if (a[(d + 1) % 4]) {
        if (a[(d + 3) % 4]) {
          if (f == 1) break;
          sum = 0;
          d = (d + 2) % 4;
          f++;
        } else {
          d = (d + 3) % 4;
        }
      } else {
        if (a[(d + 3) % 4]) {
          d = (d + 1) % 4;
        } else {
          if (f == 1) break;
          sum = 0;
          d = (d + 2) % 4;
          f++;
        }
      }
    }
    i = j;
    if (f == 0 && i == 0 && d == sd) {
      break;
    }
  }
  printf("%I64d\n", sum / 2);
  return 0;
}