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;
const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b, T c = -1234567, T d = -1234567) {
  T ans = a > b ? a : b;
  if (c != -1234567) ans = max1(ans, c);
  if (d != -1234567) ans = max1(ans, d);
  return ans;
}
template <class T>
inline T min1(T a, T b, T c = -1234567, T d = -1234567) {
  T ans = a < b ? a : b;
  if (c != -1234567) ans = min(ans, c);
  if (d != -1234567) ans = min(ans, d);
  return ans;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
template <class T>
inline T lb(T num) {
  return num & (-num);
}
inline int jud(pair<int, int> &a, pair<int, int> &b) {
  if (a < b) return -1;
  if (a == b) return 0;
  return 1;
}
template <class t>
inline int find(t val, t *a, int na, bool f_small = 1, bool f_lb = 1) {
  if (na == 1) return 0;
  int be = 0, en = na - 1;
  if (a[0] <= a[na - 1]) {
    if (f_lb == 0)
      while (be < en) {
        int mid = (be + en + 1) / 2;
        if (jud(a[mid], val) != 1)
          be = mid;
        else
          en = mid - 1;
      }
    else
      while (be < en) {
        int mid = (be + en) / 2;
        if (jud(a[mid], val) != -1)
          en = mid;
        else
          be = mid + 1;
      }
    if (f_small && jud(a[be], val) == 1 && be != 0) be--;
    if (!f_small && jud(a[be], val) == -1 && be != na - 1) be++;
  } else {
    if (f_lb)
      while (be < en) {
        int mid = (be + en + 1) / 2;
        if (jud(a[mid], val) != -1)
          be = mid;
        else
          en = mid - 1;
      }
    else
      while (be < en) {
        int mid = (be + en) / 2;
        if (jud(a[mid], val) != 1)
          en = mid;
        else
          be = mid + 1;
      }
    if (!f_small && jud(a[be], val) == -1 && be != 0) be--;
    if (f_small && jud(a[be], val) == 1 && be != na - 1) be++;
  }
  return be;
}
inline int bitnum(unsigned long long nValue) {
  nValue = ((0xaaaaaaaaaaaaaaaaull & nValue) >> 1) +
           (0x5555555555555555ull & nValue);
  nValue = ((0xccccccccccccccccull & nValue) >> 2) +
           (0x3333333333333333ull & nValue);
  nValue = ((0xf0f0f0f0f0f0f0f0ull & nValue) >> 4) +
           (0x0f0f0f0f0f0f0f0full & nValue);
  nValue = ((0xff00ff00ff00ff00ull & nValue) >> 8) +
           (0x00ff00ff00ff00ffull & nValue);
  nValue = ((0xffff0000ffff0000ull & nValue) >> 16) +
           (0x0000ffff0000ffffull & nValue);
  nValue = ((0xffffffff00000000ull & nValue) >> 32) +
           (0x00000000ffffffffull & nValue);
  return nValue;
}
long long pow(long long n, long long m, long long mod = 0) {
  long long ans = 1;
  long long k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (mod) ans %= mod;
    }
    k *= k;
    if (mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
const int step[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
const int dir[4][2] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
const int maxn = 100100;
int n, m, nkuai;
pair<int, int> kuai[maxn * 8];
int dp[maxn * 8];
vector<pair<int, int> > addkuai[maxn * 2 + 100], minukuai[maxn * 2 + 100];
int sx, sy;
int direction;
bool f = 0;
inline bool have(pair<int, int> co) {
  int k = find(co, kuai, nkuai);
  if (kuai[k] == co) return 1;
  return 0;
}
long long justdoit(int randirection) {
  long long ans = 0;
  pair<int, int> p = make_pair(sx, sy);
  int direction = randirection;
  long long l1 = 0;
  for (int k = 0;; k++) {
    int nxtdirection;
    vector<pair<int, int> >::iterator it;
    if (direction == 0 || direction == 2)
      it = lower_bound(minukuai[p.first - p.second + maxn].begin(),
                       minukuai[p.first - p.second + maxn].end(), p);
    else
      it = lower_bound(addkuai[p.first + p.second].begin(),
                       addkuai[p.first + p.second].end(), p);
    if (direction == 0 || direction == 1) it--;
    int loc = find(*it, kuai, nkuai);
    ans = ans + abs(it->first - p.first);
    if (k == 0) l1 = ans;
    int biao = 0;
    if (!have(make_pair(it->first + step[direction][0],
                        it->second + step[direction][1]))) {
      biao |= 1;
      p = make_pair(it->first + step[direction][0],
                    it->second + step[direction][1]);
      nxtdirection = (direction + 1) % 4;
    }
    if (!have(make_pair(it->first + step[(direction + 1) % 4][0],
                        it->second + step[(direction + 1) % 4][1]))) {
      biao |= 2;
      if (biao != 3)
        p = make_pair(it->first + step[(direction + 1) % 4][0],
                      it->second + step[(direction + 1) % 4][1]);
      nxtdirection = (direction + 3) % 4;
    }
    if (biao == 3 || biao == 0) {
      if (!f) {
        f = 1;
        return ans + justdoit((randirection + 2) % 4) - 1;
      }
      return ans;
    }
    if (dp[loc] & (1 << direction)) return ans - l1;
    dp[loc] |= 1 << direction;
    direction = nxtdirection;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d", &nkuai);
  for (int i = 0; i < nkuai; i++) {
    scanf("%d%d", &kuai[i].first, &kuai[i].second);
    addkuai[kuai[i].first + kuai[i].second].push_back(kuai[i]);
    minukuai[kuai[i].first - kuai[i].second + maxn].push_back(kuai[i]);
  }
  for (int j = 0; j <= m; j++) {
    kuai[nkuai].first = 0;
    kuai[nkuai].second = j;
    addkuai[kuai[nkuai].first + kuai[nkuai].second].push_back(kuai[nkuai]);
    minukuai[kuai[nkuai].first - kuai[nkuai].second + maxn].push_back(
        kuai[nkuai]);
    nkuai++;
    kuai[nkuai].first = n + 1;
    kuai[nkuai].second = j + 1;
    addkuai[kuai[nkuai].first + kuai[nkuai].second].push_back(kuai[nkuai]);
    minukuai[kuai[nkuai].first - kuai[nkuai].second + maxn].push_back(
        kuai[nkuai]);
    nkuai++;
  }
  for (int i = 0; i <= n; i++) {
    kuai[nkuai].first = i;
    kuai[nkuai].second = m + 1;
    addkuai[kuai[nkuai].first + kuai[nkuai].second].push_back(kuai[nkuai]);
    minukuai[kuai[nkuai].first - kuai[nkuai].second + maxn].push_back(
        kuai[nkuai]);
    nkuai++;
    kuai[nkuai].first = i + 1;
    kuai[nkuai].second = 0;
    addkuai[kuai[nkuai].first + kuai[nkuai].second].push_back(kuai[nkuai]);
    minukuai[kuai[nkuai].first - kuai[nkuai].second + maxn].push_back(
        kuai[nkuai]);
    nkuai++;
  }
  sort(kuai, kuai + nkuai);
  for (int i = 0; i <= n + m + 2; i++)
    sort(addkuai[i].begin(), addkuai[i].end());
  for (int j = maxn - m - 1; j <= maxn + n + 1; j++)
    sort(minukuai[j].begin(), minukuai[j].end());
  scanf("%d%d", &sx, &sy);
  char ch[3];
  scanf("%s", ch);
  if (ch[0] == 'N' && ch[1] == 'W') direction = 0;
  if (ch[0] == 'N' && ch[1] == 'E') direction = 1;
  if (ch[0] == 'S' && ch[1] == 'E') direction = 2;
  if (ch[0] == 'S' && ch[1] == 'W') direction = 3;
  cout << justdoit(direction) << endl;
  return 0;
}