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;
template <class T>
inline T min(T &a, T &b) {
  return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
  return a > b ? a : b;
}
template <class T>
void read(T &x) {
  char ch;
  while ((ch = getchar()) && !isdigit(ch))
    ;
  x = ch - '0';
  while ((ch = getchar()) && isdigit(ch)) x = x * 10 + ch - '0';
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
const int N = 400000;
set<pair<int, int> > F_s[N], S_s[N];
set<pair<int, int> >::iterator It1;
set<pair<int, int>, greater<pair<int, int> > > F_b[N], S_b[N];
set<pair<int, int>, greater<pair<int, int> > >::iterator It2;
map<pair<int, int>, bool> Hash;
long long ans = 1;
int n, m, Sx, Sy;
int Get_dir(char s[]) {
  if (s[0] == 'N' && s[1] == 'E')
    return 0;
  else if (s[0] == 'N' && s[1] == 'W')
    return 1;
  else if (s[0] == 'S' && s[1] == 'W')
    return 2;
  else
    return 3;
}
int Flag;
int vis(int x, int y) { return Hash.count(make_pair(x, y)); }
void add(int x, int y) {
  Hash[make_pair(x, y)] = 1;
  F_s[x + y].insert(make_pair(x, y)), F_b[x + y].insert(make_pair(x, y));
  S_s[x - y + m + 1].insert(make_pair(x, y)),
      S_b[x - y + m + 1].insert(make_pair(x, y));
}
int dis(pair<int, int> a, pair<int, int> b) {
  assert(abs(a.first - b.first) == abs(a.second - b.second));
  return abs(a.first - b.first);
}
int In_line(pair<int, int> x, pair<int, int> a, pair<int, int> b) {
  int X = x.first, x1 = a.first, x2 = b.first, y1 = a.second, y2 = b.second;
  if (!(x.first >= min(a.first, b.first) && x.first <= max(a.first, b.first)))
    return 0;
  return (x.second - y1) * (x2 - x1) == (X - x1) * (y2 - y1);
}
pair<pair<int, int>, int> Get_nxt(pair<int, int> Now, int dir) {
  int ax, ay, V1, V2;
  if (!dir) {
    It2 = F_b[Now.first + Now.second].lower_bound(
        make_pair(Now.first, Now.second));
    ax = It2->first, ay = It2->second;
    V1 = vis(ax, ay - 1), V2 = vis(ax + 1, ay);
    if (Now != make_pair(Sx, Sy) &&
        In_line(make_pair(Sx, Sy), Now, make_pair(ax, ay))) {
      Flag = 2;
      ans += (long long)dis(Now, make_pair(Sx, Sy)) - 1;
      return make_pair(make_pair(0, 0), dir);
    } else
      ans += dis(Now, make_pair(ax + 1, ay - 1));
    if (!V1 && !V2) return Flag = 1, make_pair(make_pair(ax + 1, ay - 1), 2);
    if (V1 && !V2) return make_pair(make_pair(ax + 1, ay), 3);
    if (!V1 && V2) return make_pair(make_pair(ax, ay - 1), 1);
    return Flag = 1, make_pair(make_pair(ax + 1, ay - 1), 2);
  } else if (dir == 1) {
    It2 = S_b[Now.first - Now.second + m + 1].lower_bound(
        make_pair(Now.first, Now.second));
    ax = It2->first, ay = It2->second;
    V1 = vis(ax + 1, ay), V2 = vis(ax, ay + 1);
    if (Now != make_pair(Sx, Sy) &&
        In_line(make_pair(Sx, Sy), Now, make_pair(ax, ay))) {
      Flag = 2;
      ans += (long long)dis(Now, make_pair(Sx, Sy)) - 1;
      return make_pair(make_pair(0, 0), dir);
    } else
      ans += dis(Now, make_pair(ax + 1, ay + 1));
    if (!V1 && !V2) return Flag = 1, make_pair(make_pair(ax + 1, ay + 1), 3);
    if (V1 && !V2) return make_pair(make_pair(ax, ay + 1), 0);
    if (!V1 && V2) return make_pair(make_pair(ax + 1, ay), 2);
    return Flag = 1, make_pair(make_pair(ax + 1, ay + 1), 3);
  } else if (dir == 2) {
    It1 = F_s[Now.first + Now.second].lower_bound(
        make_pair(Now.first, Now.second));
    ax = It1->first, ay = It1->second;
    V1 = vis(ax - 1, ay), V2 = vis(ax, ay + 1);
    if (Now != make_pair(Sx, Sy) &&
        In_line(make_pair(Sx, Sy), Now, make_pair(ax, ay))) {
      Flag = 2;
      ans += (long long)dis(Now, make_pair(Sx, Sy)) - 1;
      return make_pair(make_pair(0, 0), dir);
    } else
      ans += dis(Now, make_pair(ax - 1, ay + 1));
    if (!V1 && !V2) return Flag = 1, make_pair(make_pair(ax - 1, ay + 1), 0);
    if (V1 && !V2) return make_pair(make_pair(ax, ay + 1), 3);
    if (!V1 && V2) return make_pair(make_pair(ax - 1, ay), 1);
    return Flag = 1, make_pair(make_pair(ax - 1, ay + 1), 0);
  } else {
    It1 = S_s[Now.first - Now.second + m + 1].lower_bound(
        make_pair(Now.first, Now.second));
    ax = It1->first, ay = It1->second;
    V1 = vis(ax - 1, ay), V2 = vis(ax, ay - 1);
    if (Now != make_pair(Sx, Sy) &&
        In_line(make_pair(Sx, Sy), Now, make_pair(ax, ay))) {
      Flag = 2;
      ans += (long long)dis(Now, make_pair(Sx, Sy)) - 1;
      return make_pair(make_pair(0, 0), dir);
    } else
      ans += dis(Now, make_pair(ax - 1, ay - 1));
    if (!V1 && !V2) return Flag = 1, make_pair(make_pair(ax - 1, ay - 1), 1);
    if (V1 && !V2) return make_pair(make_pair(ax, ay - 1), 2);
    if (!V1 && V2) return make_pair(make_pair(ax - 1, ay), 0);
    return Flag = 1, make_pair(make_pair(ax - 1, ay - 1), 1);
  }
}
int k, x, y, VIS[10];
char s[6];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) scanf("%d%d", &x, &y), add(x, y);
  for (int i = 1; i <= m; i++) add(n + 1, i), add(0, i);
  for (int i = 1; i <= n; i++) add(i, m + 1), add(i, 0);
  add(n + 1, m + 1);
  add(0, 0);
  add(0, m + 1);
  add(n + 1, 0);
  scanf("%d%d%s", &Sx, &Sy, s);
  pair<int, int> Now = make_pair(Sx, Sy);
  int dir = Get_dir(s), Fdir;
  while (!VIS[dir]) {
    VIS[dir] = 1;
    Flag = 0;
    Fdir = dir;
    ans--;
    while (1) {
      pair<pair<int, int>, int> T = Get_nxt(Now, dir);
      pair<int, int> Nxt = T.first;
      Now = Nxt;
      dir = T.second;
      ans++;
      if (Nxt == make_pair(Sx, Sy)) break;
      if (Flag == 1) {
        Now = make_pair(Sx, Sy);
        dir = (Fdir + 2) % 4;
        break;
      }
      if (Flag == 2) break;
    }
  }
  printf("%lld\n", ans);
}