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;
long long read() {
  char ch = getchar();
  long long x = 0, ff = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * ff;
}
void write(long long aa) {
  if (aa < 0) putchar('-'), aa = -aa;
  if (aa > 9) write(aa / 10);
  putchar('0' + aa % 10);
  return;
}
long long n, m, k, cnt;
long long ans;
long long Sx, Sy, S, T, ff;
char s[5];
long long fx[600005][4], vis[600005][4], bj[600005][4], jl[600005][4];
struct node {
  long long x, y, id;
} a[600005];
bool cmp1(node aa, node bb) {
  return aa.x - aa.y != bb.x - bb.y ? aa.x - aa.y < bb.x - bb.y : aa.y < bb.y;
}
bool cmp2(node aa, node bb) {
  return aa.x + aa.y != bb.x + bb.y ? aa.x + aa.y < bb.x + bb.y : aa.y > bb.y;
}
bool cmpx(node aa, node bb) { return aa.x != bb.x ? aa.x < bb.x : aa.y < bb.y; }
bool cmpy(node aa, node bb) { return aa.y != bb.y ? aa.y < bb.y : aa.x < bb.x; }
bool cmp(node aa, node bb) { return aa.id < bb.id; }
long long js(long long aa) {
  ff ^= 2;
  if (ff == 0) {
    if ((bj[aa][0] && bj[aa][1]) || (!bj[aa][0] && !bj[aa][1]))
      T = aa, ff = 0;
    else if (bj[aa][0])
      ff = 1, T = bj[aa][0];
    else
      ff = 3, T = bj[aa][1];
  } else if (ff == 1) {
    if ((bj[aa][1] && bj[aa][2]) || (!bj[aa][1] && !bj[aa][2]))
      T = aa, ff = 1;
    else if (bj[aa][1])
      ff = 2, T = bj[aa][1];
    else
      ff = 0, T = bj[aa][2];
  } else if (ff == 2) {
    if ((bj[aa][2] && bj[aa][3]) || (!bj[aa][2] && !bj[aa][3]))
      T = aa, ff = 2;
    else if (bj[aa][2])
      ff = 3, T = bj[aa][2];
    else
      ff = 1, T = bj[aa][3];
  } else {
    if ((bj[aa][3] && bj[aa][0]) || (!bj[aa][3] && !bj[aa][0]))
      T = aa, ff = 3;
    else if (bj[aa][3])
      ff = 0, T = bj[aa][3];
    else
      ff = 2, T = bj[aa][0];
  }
  if (vis[T][ff]) return 0;
  vis[T][ff] = 1;
  if (!jl[T][ff]) {
    jl[T][ff] = 1;
    jl[fx[T][ff]][ff ^ 2] = 1;
    ans += (long long)abs(a[T].x - a[fx[T][ff]].x) - 1;
  }
  return 1;
}
void solve() {
  while (js(fx[T][ff]))
    ;
  return;
}
int main() {
  n = read(), m = read(), k = read();
  a[++cnt].x = 0;
  a[cnt].y = 0;
  a[cnt].id = cnt;
  a[++cnt].x = 0;
  a[cnt].y = m + 1;
  a[cnt].id = cnt;
  a[++cnt].x = n + 1;
  a[cnt].y = 0;
  a[cnt].id = cnt;
  a[++cnt].x = n + 1;
  a[cnt].y = m + 1;
  a[cnt].id = cnt;
  for (long long i = 1; i <= n; ++i) {
    a[++cnt].x = i;
    a[cnt].y = 0;
    a[cnt].id = cnt;
    a[++cnt].x = i;
    a[cnt].y = m + 1;
    a[cnt].id = cnt;
  }
  for (long long i = 1; i <= m; ++i) {
    a[++cnt].x = 0;
    a[cnt].y = i;
    a[cnt].id = cnt;
    a[++cnt].x = n + 1;
    a[cnt].y = i;
    a[cnt].id = cnt;
  }
  for (long long i = 1; i <= k; ++i)
    a[++cnt].x = read(), a[cnt].y = read(), a[cnt].id = cnt;
  Sx = read(), Sy = read();
  scanf("%s", s);
  for (long long i = 1; i <= cnt; ++i)
    if (Sx - Sy == a[i].x - a[i].y) {
      if (s[0] == 'S' && s[1] == 'E' && a[i].y > Sy)
        S = (!S || a[S].y > a[i].y) ? i : S, ff = 2;
      if (s[0] == 'N' && s[1] == 'W' && a[i].y < Sy)
        S = (!S || a[S].y < a[i].y) ? i : S, ff = 0;
    } else if (Sx + Sy == a[i].x + a[i].y) {
      if (s[0] == 'S' && s[1] == 'W' && a[i].y < Sy)
        S = (!S || a[S].y < a[i].y) ? i : S, ff = 3;
      if (s[0] == 'N' && s[1] == 'E' && a[i].y > Sy)
        S = (!S || a[S].y > a[i].y) ? i : S, ff = 1;
    }
  sort(a + 1, a + cnt + 1, cmp1);
  for (long long i = 1; i < cnt; ++i)
    if (a[i].x - a[i].y == a[i + 1].x - a[i + 1].y) {
      fx[a[i].id][2] = a[i + 1].id;
      fx[a[i + 1].id][0] = a[i].id;
    }
  sort(a + 1, a + cnt + 1, cmp2);
  for (long long i = 1; i < cnt; ++i)
    if (a[i].x + a[i].y == a[i + 1].x + a[i + 1].y) {
      fx[a[i].id][3] = a[i + 1].id;
      fx[a[i + 1].id][1] = a[i].id;
    }
  sort(a + 1, a + cnt + 1, cmpx);
  for (long long i = 1; i < cnt; ++i)
    if (a[i].x == a[i + 1].x && a[i].y + 1 == a[i + 1].y) {
      bj[a[i].id][2] = a[i + 1].id;
      bj[a[i + 1].id][0] = a[i].id;
    }
  sort(a + 1, a + cnt + 1, cmpy);
  for (long long i = 1; i < cnt; ++i)
    if (a[i].y == a[i + 1].y && a[i].x + 1 == a[i + 1].x) {
      bj[a[i].id][3] = a[i + 1].id;
      bj[a[i + 1].id][1] = a[i].id;
    }
  sort(a + 1, a + cnt + 1, cmp);
  js(S);
  solve();
  write(ans);
  return 0;
}