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;
vector<int> d1[300000];
vector<int> d2[300000];
int n, m, q;
int x[100001], y[100001];
long long cnt = 0;
int sx, sy;
int sdx, sdy;
bool mark;
int find1(int x1, int y1) {
  int l = 0;
  int r = d1[x1].size() - 1;
  int mid, re = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    if (d1[x1][mid] > y1)
      r = mid - 1;
    else
      re = mid, l = mid + 1;
  }
  return re;
}
int find2(int x1, int y1) {
  int l = 0;
  int r = d2[y1].size() - 1;
  int mid, re = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    if (d2[y1][mid] > x1)
      r = mid - 1;
    else
      re = mid, l = mid + 1;
  }
  return re;
}
bool check(int x0, int y0) {
  int tx = x0 + y0;
  int ty = x0 - y0 + m;
  int t1 = find1(tx, ty);
  int x1 = (d1[tx][t1] + tx - m) / 2;
  int y1 = (tx - d1[tx][t1] + m) / 2;
  return x0 == x1 && y0 == y1;
}
void move(int &x0, int &y0, int &dirx, int &diry, int flag) {
  int tx = x0 + y0;
  int ty = x0 - y0 + m;
  int dx, dy, nx, ny;
  int t1, x1, y1;
  if (dirx == diry) {
    t1 = find2(tx, ty);
    if (dirx == 1) t1++;
    x1 = (d2[ty][t1] + ty - m) / 2;
    y1 = (d2[ty][t1] - ty + m) / 2;
  } else {
    t1 = find1(tx, ty);
    if (dirx == 1) t1++;
    x1 = (d1[tx][t1] + tx - m) / 2;
    y1 = (tx - d1[tx][t1] + m) / 2;
  }
  bool o1 = check(x1 - dirx, y1);
  bool o2 = check(x1, y1 - diry);
  if ((o1 && o2) || ((!o1) && (!o2))) {
    mark = true;
    dx = x1 - dirx;
    dy = y1 - diry;
    nx = -dirx;
    ny = -diry;
  } else if (o1) {
    dx = x1;
    dy = y1 - diry;
    nx = dirx;
    ny = -diry;
  } else {
    dx = x1 - dirx;
    dy = y1;
    nx = -dirx;
    ny = diry;
  }
  cnt += (long long)((x1 - x0) * dirx * flag);
  x0 = dx;
  y0 = dy;
  dirx = nx;
  diry = ny;
  return;
}
void go(int x0, int y0, int dirx, int diry) {
  while (true) {
    move(x0, y0, dirx, diry, 1);
    if (x0 == sx && y0 == sy && dirx == sdx && diry == sdy) return;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  n++;
  m++;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x[i], &y[i]);
    d1[x[i] + y[i]].push_back(x[i] - y[i] + m);
    d2[x[i] - y[i] + m].push_back(x[i] + y[i]);
  }
  for (int i = 0; i <= n; i++) {
    d1[i + 0].push_back(i - 0 + m);
    d2[i - 0 + m].push_back(i + 0);
    d1[i + m].push_back(i - m + m);
    d2[i - m + m].push_back(i + m);
  }
  for (int i = 1; i < m; i++) {
    d1[i + 0].push_back(0 - i + m);
    d2[0 - i + m].push_back(i + 0);
    d1[i + n].push_back(n - i + m);
    d2[n - i + m].push_back(i + n);
  }
  int x0, y0, dirx, diry;
  char c[10];
  scanf("%d%d", &x0, &y0);
  scanf("%s", c);
  if (c[0] == 'S')
    dirx = 1;
  else
    dirx = -1;
  if (c[1] == 'E')
    diry = 1;
  else
    diry = -1;
  for (int i = 0; i <= n + m; i++) sort(d1[i].begin(), d1[i].end());
  for (int i = 0; i <= n + m; i++) sort(d2[i].begin(), d2[i].end());
  move(x0, y0, dirx, diry, 0);
  sx = x0, sy = y0;
  sdx = dirx, sdy = diry;
  go(x0, y0, dirx, diry);
  printf("%I64d\n", cnt / (mark ? 2ll : 1ll));
  return 0;
}