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 long long mod = 1000000007;
struct point {
  int r, c;
};
struct line {
  point inc, ref;
  int incD, refD;
};
struct pcom {
  bool operator()(const point &a, const point &b) const {
    if (a.r < b.r) return true;
    if (a.r > b.r) return false;
    return a.c < b.c;
  }
};
struct lcom {
  bool operator()(const line &a, const line &b) const {
    if (a.incD < b.incD) return true;
    if (a.incD > b.incD) return false;
    if (a.incD == 0) {
      if (a.inc.r + a.inc.c < b.inc.r + b.inc.c) return true;
      if (a.inc.r + a.inc.c > b.inc.r + b.inc.c) return false;
      return a.inc.c < b.inc.c;
    }
    if (a.incD == 1) {
      if (a.inc.r - a.inc.c < b.inc.r - b.inc.c) return true;
      if (a.inc.r - a.inc.c > b.inc.r - b.inc.c) return false;
      return a.inc.c > b.inc.c;
    }
    if (a.incD == 2) {
      if (a.inc.r - a.inc.c < b.inc.r - b.inc.c) return true;
      if (a.inc.r - a.inc.c > b.inc.r - b.inc.c) return false;
      return a.inc.c < b.inc.c;
    }
    if (a.incD == 3) {
      if (a.inc.r + a.inc.c < b.inc.r + b.inc.c) return true;
      if (a.inc.r + a.inc.c > b.inc.r + b.inc.c) return false;
      return a.inc.c > b.inc.c;
    }
    return true;
  }
};
void pin(line &pos) {
  cout << pos.inc.r << ' ' << pos.inc.c << ' ' << pos.incD << ' ' << pos.ref.r
       << ' ' << pos.ref.c << ' ' << pos.refD << ' ' << endl;
}
long long che(line &a, line &b, vector<vector<pair<int, int> > > &rd,
              vector<vector<pair<int, int> > > &ru, int n, int m) {
  long long res = 0;
  if (a.incD == 1 || a.incD == 2) {
    int aa = min(a.inc.r + a.inc.c - 2, b.inc.r + b.inc.c - 2),
        bb = max(a.inc.r + a.inc.c - 2, b.inc.r + b.inc.c - 2);
    int cc = n - 1 - a.inc.r + a.inc.c;
    ru[aa].push_back(make_pair(cc, 1));
    ru[bb].push_back(make_pair(cc, -1));
    for (long long i = 0; i < cc; ++i)
      for (long long j = 0; j < ((int)(rd[i]).size()); ++j)
        if (aa <= rd[i][j].first && rd[i][j].first <= bb)
          res += rd[i][j].second;
  } else {
    int aa = min(n - 1 - a.inc.r + a.inc.c, n - 1 - b.inc.r + b.inc.c),
        bb = max(n - 1 - a.inc.r + a.inc.c, n - 1 - b.inc.r + b.inc.c);
    int cc = a.inc.r + a.inc.c - 2;
    rd[aa].push_back(make_pair(cc, 1));
    rd[bb].push_back(make_pair(cc, -1));
    for (long long i = 0; i < cc; ++i)
      for (long long j = 0; j < ((int)(ru[i]).size()); ++j)
        if (aa <= ru[i][j].first && ru[i][j].first <= bb)
          res += ru[i][j].second;
  }
  return res;
}
int ml(line tem, int n) {
  int res;
  if (tem.incD == 1 || tem.incD == 2) {
    res = n - 1 - tem.inc.r + tem.inc.c;
  } else {
    res = tem.inc.r + tem.inc.c - 2;
  }
  return res;
}
void myinsert(deque<deque<bool> > &occ, int oa, int ob,
              vector<vector<set<line, lcom> > > &lin, point &itt, int da,
              int db, int dc, int n) {
  if (!occ[oa][ob]) {
    if (occ[1][ob] && !occ[oa][1]) {
      line tem;
      tem.inc.r = tem.ref.r = itt.r + oa - 1;
      tem.inc.c = itt.c + ob - 1;
      tem.incD = da;
      tem.ref.c = itt.c;
      tem.refD = db;
      lin[da][ml(tem, n)].insert(tem);
    } else if (!occ[1][ob] && occ[oa][1]) {
      line tem;
      tem.inc.c = tem.ref.c = itt.c + ob - 1;
      tem.inc.r = itt.r + oa - 1;
      tem.incD = da;
      tem.ref.r = itt.r;
      tem.refD = dc;
      lin[da][ml(tem, n)].insert(tem);
    } else {
      line tem;
      tem.inc.c = tem.ref.c = itt.c + ob - 1;
      tem.inc.r = tem.ref.r = itt.r + oa - 1;
      tem.incD = da;
      tem.refD = 3 - da;
      lin[da][ml(tem, n)].insert(tem);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  set<point, pcom> bc;
  for (long long i = 0; i < n + 2; ++i) {
    point p;
    p.r = i;
    p.c = 0;
    bc.insert(p);
    p.c = m + 1;
    bc.insert(p);
  }
  for (long long i = 0; i < m + 2; ++i) {
    point p;
    p.r = 0;
    p.c = i;
    bc.insert(p);
    p.r = n + 1;
    bc.insert(p);
  }
  for (long long i = 0; i < k; ++i) {
    point p;
    cin >> p.r >> p.c;
    bc.insert(p);
  }
  line start;
  string s;
  cin >> start.inc.r >> start.inc.c >> s;
  if (s == "NE") start.incD = 0;
  if (s == "NW") start.incD = 1;
  if (s == "SE") start.incD = 2;
  if (s == "SW") start.incD = 3;
  vector<vector<set<line, lcom> > > lin(
      4, vector<set<line, lcom> >(n + m - 1, set<line, lcom>()));
  for (set<point, pcom>::iterator it = bc.begin(); it != bc.end(); ++it) {
    point itt = *it;
    deque<deque<bool> > occ(3, deque<bool>(3, false));
    for (long long i = 0; i < 3; ++i)
      for (long long j = 0; j < 3; ++j) {
        point tem = *it;
        tem.r += i - 1;
        tem.c += j - 1;
        if (tem.r < 0 || tem.r > n + 1 || tem.c < 0 || tem.c > m + 1 ||
            bc.count(tem))
          occ[i][j] = true;
      }
    myinsert(occ, 0, 0, lin, itt, 2, 0, 3, n);
    myinsert(occ, 0, 2, lin, itt, 3, 1, 2, n);
    myinsert(occ, 2, 2, lin, itt, 1, 3, 0, n);
    myinsert(occ, 2, 0, lin, itt, 0, 2, 1, n);
  }
  set<line, lcom>::iterator it;
  it = lin[start.incD][ml(start, n)].lower_bound(start);
  line pos = *it, spos = *it;
  vector<vector<pair<int, int> > > rd(n + m - 1), ru(n + m - 1);
  bool aga = false, single = false;
  long long res = 0;
  while (!aga || (pos.inc.r != spos.inc.r || pos.inc.c != spos.inc.c ||
                  pos.incD != spos.incD)) {
    aga = true;
    if (pos.incD + pos.refD == 3) {
      single = true;
      break;
    }
    line tem;
    tem.inc.r = pos.ref.r;
    tem.inc.c = pos.ref.c;
    tem.incD = pos.refD;
    it = lin[tem.incD][ml(tem, n)].lower_bound(tem);
    pos = *it;
    res += abs(pos.inc.r - tem.inc.r) + 1;
  }
  if (single) {
    pos = spos;
    pos.ref.r = pos.inc.r;
    pos.ref.c = pos.inc.c;
    pos.refD = 3 - pos.incD;
    aga = false;
    while (!aga || pos.incD + pos.refD != 3) {
      aga = true;
      line tem;
      tem.inc.r = pos.ref.r;
      tem.inc.c = pos.ref.c;
      tem.incD = pos.refD;
      it = lin[tem.incD][ml(tem, n)].lower_bound(tem);
      pos = *it;
      res += abs(pos.inc.r - tem.inc.r) + 1;
    }
  }
  cout << res << endl;
  return 0;
}