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;
int n, m, k, id;
map<pair<int, int>, int> ord;
pair<int, int> loc[5 * 100100];
int _x[] = {-1, -1, 1, 1};
int _y[] = {1, -1, -1, 1};
bool acc[5 * 100100][4];
vector<pair<int, int> > l[2][2 * 100100];
inline int code0(pair<int, int> a) { return a.first + a.second; }
inline int code1(pair<int, int> a) { return a.first + m + 1 - a.second; }
void insert(pair<int, int> a) {
  ord[a] = id;
  loc[id] = a;
  id++;
  l[0][code0(a)].push_back(a);
  l[1][code1(a)].push_back(a);
}
int nxt_dir(int dir, pair<int, int> a) {
  int x = a.first, y = a.second;
  bool l = (ord.find(make_pair(x, y - 1)) == ord.end()) ? false : true,
       r = (ord.find(make_pair(x, y + 1)) == ord.end()) ? false : true,
       u = (ord.find(make_pair(x - 1, y)) == ord.end()) ? false : true,
       d = (ord.find(make_pair(x + 1, y)) == ord.end()) ? false : true;
  if (dir == 0) {
    if (l && d) return 2;
    if (!l && !d) return 2;
    if (l) return 3;
    return 1;
  }
  if (dir == 1) {
    if (r && d) return 3;
    if (!r && !d) return 3;
    if (r) return 2;
    return 0;
  }
  if (dir == 2) {
    if (u && r) return 0;
    if (!u && !r) return 0;
    if (u) return 3;
    return 1;
  }
  if (dir == 3) {
    if (u && l) return 1;
    if (!u && !l) return 1;
    if (u) return 2;
    return 0;
  }
}
map<pair<int, int>, int> route;
inline int less_than(vector<pair<int, int> > &v, pair<int, int> g) {
  int ll = 0, rr = v.size() - 1, mid, t = 0;
  while (ll <= rr) {
    mid = ll + rr >> 1;
    if (v[mid] < g)
      t = mid, ll = mid + 1;
    else
      rr = mid - 1;
  }
  return ord[v[t]];
}
inline int greater_than(vector<pair<int, int> > &v, pair<int, int> g) {
  int ll = 0, rr = v.size() - 1, mid, t = v.size() - 1;
  while (ll <= rr) {
    mid = ll + rr >> 1;
    if (v[mid] >= g)
      t = mid, rr = mid - 1;
    else
      ll = mid + 1;
  }
  return ord[v[t]];
}
inline pair<int, int> nxt_fr(int dir, int ndir, pair<int, int> block) {
  int x = (_x[dir] == _x[ndir]) ? block.first : (block.first + _x[ndir]);
  int y = (_y[dir] == _y[ndir]) ? block.second : (block.second + _y[ndir]);
  return make_pair(x, y);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i <= m + 1; i++)
    insert(make_pair(0, i)), insert(make_pair(n + 1, i));
  for (int i = 1; i <= n; i++)
    insert(make_pair(i, 0)), insert(make_pair(i, m + 1));
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    insert(make_pair(a, b));
  }
  for (int i = 0; i < 2 * 100100; i++)
    sort(l[0][i].begin(), l[0][i].end()), sort(l[1][i].begin(), l[1][i].end());
  int dir;
  string _in;
  pair<int, int> fr, block = make_pair(-1, -1);
  cin >> fr.first >> fr.second >> _in;
  if (_in == "NE") dir = 0;
  if (_in == "NW") dir = 1;
  if (_in == "SE") dir = 3;
  if (_in == "SW") dir = 2;
  while (ord.find(block) == ord.end() || acc[ord[block]][dir] == false) {
    if (ord.find(block) != ord.end()) acc[ord[block]][dir] = true;
    pair<int, int> nfr, nblock;
    int ndir;
    int hid, tid;
    if (dir == 0 || dir == 2)
      hid = less_than(l[0][code0(fr)], fr),
      tid = greater_than(l[0][code0(fr)], fr);
    else
      hid = less_than(l[1][code1(fr)], fr),
      tid = greater_than(l[1][code1(fr)], fr);
    if (dir == 2 || dir == 3)
      nblock = loc[tid];
    else
      nblock = loc[hid];
    ndir = nxt_dir(dir, nblock);
    nfr = nxt_fr(dir, ndir, nblock);
    int D;
    pair<int, int> arrt;
    arrt = make_pair(nblock.first - _x[dir], nblock.second - _y[dir]);
    D = abs(arrt.first - fr.first) + 1;
    if (route.find(make_pair(hid, tid)) == route.end()) {
      route[make_pair(hid, tid)] = D;
    } else {
      if (route[make_pair(hid, tid)]) {
        route[make_pair(hid, tid)] = D;
      }
    }
    fr = nfr, dir = ndir, block = nblock;
  }
  long long ans = 0;
  map<pair<int, int>, int>::iterator it = route.begin();
  for (; it != route.end(); it++) {
    ans += (long long)(it->second);
  }
  cout << ans << endl;
}