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;
inline long long read() {
  long long f = 0, s = 0;
  char c = getchar();
  while (c > '9' || c < '0') f = (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    s = (s << 3) + (s << 1) + (c ^ '0'), c = getchar();
  return f ? -s : s;
}
long long n, m, k;
vector<long long> ch[200005];
vector<long long> he[200005];
long long it1, it2;
long long t1, t2;
long long sx, sy, sfx;
long long tx, ty, tfx;
long long nx, ny;
char cc[5];
long long ans = 0;
bool flag = 0;
inline long long ne(long long op, long long t, long long x) {
  if (op == 1)
    return ch[t][upper_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin()];
  else
    return he[t][upper_bound(he[t].begin(), he[t].end(), x) - he[t].begin()];
}
inline long long ft(long long op, long long t, long long x) {
  if (op == 1)
    return ch[t]
             [lower_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin() - 1];
  else
    return he[t]
             [lower_bound(he[t].begin(), he[t].end(), x) - he[t].begin() - 1];
}
inline long long fd(long long op, long long t, long long x) {
  if (op == 1) {
    long long tt = lower_bound(ch[t].begin(), ch[t].end(), x) - ch[t].begin();
    if (tt >= ch[t].size()) return -1;
    if (ch[t][tt] == x)
      return tt;
    else
      return -1;
  } else {
    long long tt = lower_bound(he[t].begin(), he[t].end(), x) - he[t].begin();
    if (tt >= he[t].size()) return -1;
    if (he[t][tt] == x)
      return tt;
    else
      return -1;
  }
}
bool ff = 1, fff = 1;
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; i++) {
    t1 = read();
    t2 = read();
    ch[t2 - t1 + n + 1].push_back(t1);
    he[t1 + t2].push_back(t1);
  }
  for (int i = 0; i <= n + 1; i++) {
    ch[m + 1 - i + n + 1].push_back(i);
    he[m + 1 + i].push_back(i);
    ch[-i + n + 1].push_back(i);
    he[i].push_back(i);
  }
  for (int i = 0; i <= m + 1; i++) {
    ch[i + n + 1].push_back(0);
    he[i].push_back(0);
    ch[i - n - 1 + n + 1].push_back(n + 1);
    he[n + 1 + i].push_back(n + 1);
  }
  for (int i = 0; i <= n + m + 2; i++) sort(he[i].begin(), he[i].end());
  for (int i = 0; i <= m + n + 2; i++) sort(ch[i].begin(), ch[i].end());
  sx = read();
  sy = read();
  scanf("%s", cc);
  if (cc[0] == 'N') {
    if (cc[1] == 'E')
      sfx = 0;
    else
      sfx = 1;
  } else {
    if (cc[1] == 'E')
      sfx = 2;
    else
      sfx = 3;
  }
  tx = sx;
  ty = sy;
  tfx = sfx;
  sx = sy = sfx = -1;
  while (tx != sx || ty != sy || tfx != sfx || fff) {
    if (fff && tx == sx && ty == sy && tfx == sfx) fff = 0;
    if (tfx == 0) {
      nx = ne(2, tx + ty, tx);
      ny = tx + ty - nx;
      ans += nx - tx;
      it1 = fd(2, tx + ty - 1, nx - 1);
      it2 = fd(2, tx + ty + 1, nx);
      if (it1 != -1 && it2 != -1) {
        tfx = 3;
        tx = nx - 1;
        ty = ny + 1;
        flag = 1;
      } else if (it1 != -1) {
        tfx = 2;
        tx = nx;
        ty = ny + 1;
      } else if (it2 != -1) {
        tfx = 1;
        tx = nx - 1;
        ty = ny;
      } else {
        tfx = 3;
        tx = nx - 1;
        ty = ny + 1;
        flag = 1;
      }
    } else if (tfx == 3) {
      nx = ft(2, tx + ty, tx);
      ny = tx + ty - nx;
      ans += tx - nx;
      it1 = fd(2, tx + ty - 1, nx);
      it2 = fd(2, tx + ty + 1, nx + 1);
      if (it1 != -1 && it2 != -1) {
        tfx = 0;
        tx = nx + 1;
        ty = ny - 1;
        flag = 1;
      } else if (it1 != -1) {
        tfx = 2;
        tx = nx + 1;
        ty = ny;
      } else if (it2 != -1) {
        tfx = 1;
        tx = nx;
        ty = ny - 1;
      } else {
        tfx = 0;
        tx = nx + 1;
        ty = ny - 1;
        flag = 1;
      }
    } else if (tfx == 2) {
      nx = ne(1, ty - tx + n + 1, tx);
      ny = ty - tx + nx;
      ans += nx - tx;
      it1 = fd(1, ty - tx + n + 1 - 1, nx);
      it2 = fd(1, ty - tx + n + 1 + 1, nx - 1);
      if (it1 != -1 && it2 != -1) {
        tfx = 1;
        tx = nx - 1;
        ty = ny - 1;
        flag = 1;
      } else if (it1 != -1) {
        tfx = 3;
        tx = nx - 1;
        ty = ny;
      } else if (it2 != -1) {
        tfx = 0;
        tx = nx;
        ty = ny - 1;
      } else {
        tfx = 1;
        tx = nx - 1;
        ty = ny - 1;
        flag = 1;
      }
    } else if (tfx == 1) {
      nx = ft(1, ty - tx + n + 1, tx);
      ny = ty - tx + nx;
      ans += tx - nx;
      it1 = fd(1, ty - tx + n + 1 - 1, nx + 1);
      it2 = fd(1, ty - tx + n + 1 + 1, nx);
      if (it1 != -1 && it2 != -1) {
        tfx = 2;
        tx = nx + 1;
        ty = ny + 1;
        flag = 1;
      } else if (it1 != -1) {
        tfx = 3;
        tx = nx;
        ty = ny + 1;
      } else if (it2 != -1) {
        tfx = 0;
        tx = nx + 1;
        ty = ny;
      } else {
        tfx = 2;
        tx = nx + 1;
        ty = ny + 1;
        flag = 1;
      }
    }
    if (ff) {
      sx = tx;
      sy = ty;
      sfx = tfx;
      ff = 0;
      ans = 0;
    }
  }
  while (tx != sx || ty != sy || tfx != sfx)
    ;
  if (flag)
    printf("%lld", ans / 2);
  else
    printf("%lld", ans);
  return 0;
}