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 stmp;
const int MAX = 200020;
const int INF = 1000000001;
int a1[2 * MAX], a2[2 * MAX];
void add(int *a, int n, int x) {
  for (; n < 2 * MAX; n |= n + 1) a[n] += x;
}
int sum(int *a, int n) {
  if (n == -1) return 0;
  int s = 0;
  while (n >= 0) {
    s += a[n];
    n = (n & (n + 1)) - 1;
  }
  return s;
}
vector<int> slash[2 * MAX], bslash[2 * MAX];
int n, m;
inline int bsnr(int x, int y) { return x - y + MAX; }
inline int snr(int x, int y) { return x + y; }
inline int bsnr(pair<int, int> p) { return bsnr(p.first, p.second); }
inline int snr(pair<int, int> p) { return snr(p.first, p.second); }
inline int bsy(int s, int y) { return s - MAX + y; }
inline int bsx(int s, int x) { return x + MAX - s; }
inline int sx(int bs, int x) { return bs - x; }
inline int sy(int bs, int y) { return bs - y; }
inline void addCell(int x, int y) {
  slash[snr(x, y)].push_back(x);
  bslash[bsnr(x, y)].push_back(x);
}
inline bool exists(int x, int y) {
  return binary_search((bslash[bsnr(x, y)]).begin(), (bslash[bsnr(x, y)]).end(),
                       x);
}
void init() {
  for (int i = 0; i < (2 * MAX); ++i) {
    sort((slash[i]).begin(), (slash[i]).end());
    sort((bslash[i]).begin(), (bslash[i]).end());
  }
}
pair<int, int> move(pair<int, int> pos, pair<int, int> dir) {
  int x, y;
  if (dir == make_pair(-1, 1)) {
    int s = snr(pos.first, pos.second);
    x = *--lower_bound((slash[s]).begin(), (slash[s]).end(), pos.first);
    y = sx(s, x);
  } else if (dir == make_pair(-1, -1)) {
    int bs = bsnr(pos.first, pos.second);
    x = *--lower_bound((bslash[bs]).begin(), (bslash[bs]).end(), pos.first);
    y = bsx(bs, x);
  } else if (dir == make_pair(1, 1)) {
    int bs = bsnr(pos.first, pos.second);
    x = *lower_bound((bslash[bs]).begin(), (bslash[bs]).end(), pos.first);
    y = bsx(bs, x);
  } else {
    int s = snr(pos.first, pos.second);
    x = *lower_bound((slash[s]).begin(), (slash[s]).end(), pos.first);
    y = sx(s, x);
  }
  return make_pair(x, y);
}
pair<int, int> pos, dir;
struct event {
  int y, x1, x2;
  event() {}
  event(int _y, int _x1, int _x2) : y(_y), x1(_x1), x2(_x2) {}
  bool operator<(const event &rhs) const { return y < rhs.y; }
};
long long solve(vector<event> &E) {
  sort((E).begin(), (E).end());
  long long ret = 0;
  for (int i = 0; i < ((int)(E).size());) {
    int k = i + 1;
    while (k < ((int)(E).size()) && E[i].y == E[k].y) ++k;
    vector<pair<int, int> > v;
    for (int j = i; j < k; ++j) {
      v.push_back(make_pair(E[j].x1, -1));
      v.push_back(make_pair(E[j].x2, 1));
    }
    sort((v).begin(), (v).end());
    for (int j = 0; j < ((int)(v).size());) {
      assert(v[j].second == -1);
      int s = v[j].second;
      for (++j; s != 0; ++j) {
        s += v[j].second;
        ret += (v[j].first - v[j - 1].first);
      }
    }
    i = k;
  }
  return ret;
}
long long solve() {
  set<pair<pair<int, int>, pair<int, int> > > vis;
  vector<event> E[2];
  do {
    vis.insert(make_pair(pos, dir));
    pair<int, int> blocked = move(pos, dir);
    if (snr(pos) == snr(blocked)) {
      int x1 = bsnr(pos) / 2, x2 = bsnr(blocked) / 2;
      if (x1 > x2) {
        ++x1, ++x2;
        swap(x1, x2);
      }
      E[0].push_back(event(snr(pos), x1, x2));
    } else {
      int x1 = snr(pos) / 2, x2 = snr(blocked) / 2;
      if (x1 > x2) {
        ++x1;
        ++x2;
        swap(x1, x2);
      }
      E[1].push_back(event(bsnr(pos), x1, x2));
    }
    pair<int, int> nextpos, nextdir;
    bool bx = exists(blocked.first, blocked.second - dir.second);
    bool by = exists(blocked.first - dir.first, blocked.second);
    if (bx == by) {
      nextpos =
          make_pair(blocked.first - dir.first, blocked.second - dir.second);
      nextdir = make_pair(-dir.first, -dir.second);
    } else if (bx) {
      nextpos = make_pair(blocked.first - dir.first, blocked.second);
      nextdir = make_pair(-dir.first, dir.second);
    } else if (by) {
      nextpos = make_pair(blocked.first, blocked.second - dir.second);
      nextdir = make_pair(dir.first, -dir.second);
    }
    pos = nextpos;
    dir = nextdir;
  } while (vis.find(make_pair(pos, dir)) == vis.end());
  return solve(E[0]) + solve(E[1]);
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0);
  int k;
  cin >> n >> m >> k;
  for (int i = (0); i <= (n + 1); ++i) addCell(i, 0), addCell(i, m + 1);
  for (int i = (1); i <= (m); ++i) addCell(0, i), addCell(n + 1, i);
  while (k--) {
    int x, y;
    cin >> x >> y;
    addCell(x, y);
  }
  init();
  cin >> pos.first >> pos.second;
  char d[3];
  cin >> d;
  dir = make_pair(d[0] == 'N' ? -1 : 1, d[1] == 'E' ? 1 : -1);
  cout << solve() << endl;
  return 0;
}