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> sg;
pair<int, int> li[1000050];
int ln[1000050][4], n, m, p, st, wz[1000050][2], cur[1000050],
    *Cur = cur + 1000050 / 2;
int Wz[1000050][2], Sx, Sy, Sg;
char c[3];
bool d[1000050], f[1000050];
long long ans;
const int Dir[4][2] = {{-1, -1}, {-1, 0}, {0, -1}, {0, 0}};
inline int Read() {
  int x = 0;
  char y;
  do y = getchar();
  while (y < '0' || y > '9');
  do x = x * 10 + y - '0', y = getchar();
  while (y >= '0' && y <= '9');
  return x;
}
inline int Insert(int x, int y) {
  pair<int, int> k = make_pair(x, y);
  if (!sg[k]) sg[k] = ++st, Wz[st][0] = x, Wz[st][1] = y;
  return sg[k];
}
void Set_sg() {
  for (int i = 1; i <= p; i++)
    for (int j = 0; j < 4; j++)
      Insert(wz[i][0] + Dir[j][0], wz[i][1] + Dir[j][1]);
  for (int i = 0; i <= m; i++) Insert(0, i), Insert(n, i);
  for (int i = 0; i <= n; i++) Insert(i, 0), Insert(i, m);
  for (int i = 1; i <= p; i++)
    if (wz[i][1] == m) f[i] = true;
  return;
}
inline void Line(int x, int y, bool z = true) {
  if (x == y || !z) return;
  int k = abs(Wz[x][0] - Wz[y][0]), l = ln[x][0] ? 2 : 0;
  ln[x][l] = y;
  ln[x][l + 1] = k;
  l = ln[y][0] ? 2 : 0;
  ln[y][l] = x;
  ln[y][l + 1] = k;
}
void Set_Lines() {
  int now = 0;
  bool flag = (c[0] == 'N') ^ (c[1] == 'E'), Flag = false;
  if (!flag)
    Sg = Insert(--Sx, Sy);
  else
    Sg = Insert(Sx, Sy);
  for (int i = 1; i <= p; i++)
    li[++now].first = wz[i][0], li[now].second = wz[i][1];
  for (int i = 1; i <= n; i++) li[++now].first = i, li[now].second = 0;
  if (!flag) li[++now].first = Sx, li[now].second = Sy;
  sort(li + 1, li + now + 1);
  for (int i = 1; i <= m; i++) Cur[i] = sg[make_pair(0, i)];
  for (int i = 1; i <= n; i++) Cur[i + m] = sg[make_pair(i, m)];
  for (int i = 1; i <= now; i++)
    if (!li[i].second)
      Line(sg[make_pair(li[i].first, 0)], Cur[li[i].first],
           i == now || li[i + 1].first != li[i].first || li[i + 1].second != 1);
    else if (!flag && li[i].first == Sx && li[i].second == Sy && !Flag)
      Flag = true, Line(Sg, Cur[Sx + Sy]), Cur[Sx + Sy] = Sg;
    else {
      if (li[i].second != m && li[i].first != 1)
        Line(sg[make_pair(li[i].first - 1, li[i].second)],
             Cur[li[i].first - 1 + li[i].second]);
      Cur[li[i].first - 1 + li[i].second] =
          sg[make_pair(li[i].first, li[i].second - 1)];
    }
  for (int i = 1; i < m; i++) Line(sg[make_pair(n, i)], Cur[n + i]);
  now = p;
  for (int i = 1; i <= p; i++) li[i].first = wz[i][0], li[i].second = wz[i][1];
  for (int i = 1; i <= n; i++) li[++now].first = i, li[now].second = -1;
  if (flag) li[++now].first = Sx, li[now].second = Sy;
  sort(li + 1, li + now + 1);
  memset(cur, 0, sizeof(cur));
  for (int i = 0; i < m; i++) Cur[-i] = sg[make_pair(0, i)];
  for (int i = 1; i < n; i++) Cur[i] = sg[make_pair(i, 0)];
  for (int i = 1; i <= now; i++)
    if (li[i].second == -1)
      Line(sg[make_pair(li[i].first, m)], Cur[li[i].first - m],
           !f[li[i].first]);
    else if (li[i].first == Sx && li[i].second == Sy && flag && !Flag)
      Flag = true, Line(Sg, Cur[Sx - Sy]), Cur[Sx - Sy] = Sg;
    else {
      if (li[i].second != 1 && li[i].first != 1)
        Line(sg[make_pair(li[i].first - 1, li[i].second - 1)],
             Cur[li[i].first - li[i].second]);
      Cur[li[i].first - li[i].second] =
          sg[make_pair(li[i].first, li[i].second)];
    }
  for (int i = 1; i < m; i++) Line(sg[make_pair(n, i)], Cur[n - i]);
}
void DFS(int x) {
  if (!x || d[x]) return;
  d[x] = true;
  ans += ln[x][1] + ln[x][3];
  DFS(ln[x][0]);
  DFS(ln[x][2]);
}
int main() {
  n = Read();
  m = Read();
  p = Read();
  if (n == 1 && m == 1) {
    puts("1");
    return 0;
  }
  for (int i = 1; i <= p; i++) wz[i][0] = Read(), wz[i][1] = Read();
  scanf("%d%d%s", &Sx, &Sy, c);
  Set_sg();
  Set_Lines();
  DFS(Sg);
  cout << ans / 2 << endl;
  return 0;
}