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;
long long int cuenta(map<int, int> v[500000], int tope) {
  long long int c = 0;
  for (int i = 0; i < tope; i++) {
    map<int, int> &m = v[i];
    map<int, int>::iterator it = m.begin();
    if (it != m.end()) {
      int pos = it->first;
      it++;
      while (it != m.end()) {
        int nextpos = it->first;
        if (it->second) c += (nextpos - pos - 1) / 2;
        pos = nextpos;
        it++;
      }
    }
  }
  return c;
}
map<int, int> colmas[500000], colmenos[500000], filmas[500000],
    filmenos[500000];
set<pair<int, int> > todos;
void simular(int i, int j, int d) {
  for (;;) {
    if (d == 0) {
      map<int, int>::iterator it = filmas[i].upper_bound(j);
      if (it->second) return;
      it->second = 1;
      j = (it->first) - 1;
      if (todos.count(pair<int, int>(i - 1, j))) {
        if (todos.count(pair<int, int>(i + 1, j))) return;
        colmenos[j][i - 1] = 1;
        d = 3;
      } else if (todos.count(pair<int, int>(i + 1, j))) {
        colmas[j][i + 1] = 1;
        d = 1;
      } else
        return;
    } else if (d == 1) {
      map<int, int>::iterator it = colmenos[j].upper_bound(i);
      it--;
      if (it->second) return;
      it->second = 1;
      i = (it->first) + 1;
      if (todos.count(pair<int, int>(i, j - 1))) {
        if (todos.count(pair<int, int>(i, j + 1))) return;
        filmenos[i][j - 1] = 1;
        d = 0;
      } else if (todos.count(pair<int, int>(i, j + 1))) {
        filmas[i][j + 1] = 1;
        d = 2;
      } else
        return;
    } else if (d == 2) {
      map<int, int>::iterator it = filmenos[i].upper_bound(j);
      it--;
      if (it->second) return;
      it->second = 1;
      j = (it->first) + 1;
      if (todos.count(pair<int, int>(i - 1, j))) {
        if (todos.count(pair<int, int>(i + 1, j))) return;
        colmenos[j][i - 1] = 1;
        d = 3;
      } else if (todos.count(pair<int, int>(i + 1, j))) {
        colmas[j][i + 1] = 1;
        d = 1;
      } else
        return;
    } else if (d == 3) {
      map<int, int>::iterator it = colmas[j].upper_bound(i);
      if (it->second) return;
      it->second = 1;
      i = (it->first) - 1;
      if (todos.count(pair<int, int>(i, j - 1))) {
        if (todos.count(pair<int, int>(i, j + 1))) return;
        filmenos[i][j - 1] = 1;
        d = 0;
      } else if (todos.count(pair<int, int>(i, j + 1))) {
        filmas[i][j + 1] = 1;
        d = 2;
      } else
        return;
    }
  }
}
int n, m, k;
void cambio(int i, int j, int &ii, int &jj) {
  ii = i + j;
  jj = i - j + m + 1;
}
void insert(int i, int j) {
  int ii, jj;
  cambio(i, j, ii, jj);
  todos.insert(pair<int, int>(ii, jj));
  colmenos[jj][ii];
  colmas[jj][ii];
  filmenos[ii][jj];
  filmas[ii][jj];
}
int primero = 1 << 19;
const int tope = 1 << 20;
int cuantos[tope];
void insertar(int pos, int val) {
  pos += primero;
  cuantos[pos] = val;
  while (pos > 1) {
    pos /= 2;
    cuantos[pos] = cuantos[2 * pos] + cuantos[2 * pos + 1];
  }
}
int cuantosentre(int inf, int sup) {
  inf += primero;
  sup += primero;
  if (inf > sup) return 0;
  if (inf == sup) return cuantos[inf];
  int c = cuantos[inf] + cuantos[sup];
  while (inf + 1 < sup) {
    if (inf % 2 == 0) c += cuantos[inf + 1];
    inf /= 2;
    if (sup % 2 == 1) c += cuantos[sup - 1];
    sup /= 2;
  }
  return c;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 0; i <= n + 1; i++) {
    insert(i, 0);
    insert(i, m + 1);
  }
  for (int j = 0; j <= m + 1; j++) {
    insert(0, j);
    insert(n + 1, j);
  }
  for (int d = 0; d < k; d++) {
    int i, j;
    cin >> i >> j;
    insert(i, j);
  }
  int ii, jj;
  string dir;
  cin >> ii >> jj >> dir;
  int i, j;
  cambio(ii, jj, i, j);
  if (dir == "NE" or dir == "SW") {
    simular(i, j, 0);
    simular(i, j, 2);
  } else {
    simular(i, j, 1);
    simular(i, j, 3);
  }
  long long int sol =
      cuenta(filmas, n + 1 + m + 1 + 1) + cuenta(colmas, n + 1 + m + 1 + 1);
  map<int, vector<int> > poner, quitar;
  for (int j = 0; j < n + 1 + m + 1 + 1; j++) {
    map<int, int> &mapa = colmas[j];
    map<int, int>::iterator it = mapa.begin();
    if (it != mapa.end()) {
      int pos = it->first;
      it++;
      while (it != mapa.end()) {
        int nextpos = it->first;
        if (it->second) {
          poner[pos + 2].push_back(j);
          quitar[nextpos - 2].push_back(j);
        }
        pos = nextpos;
        it++;
      }
    }
  }
  for (int i = 0; i < n + 1 + m + 1 + 1; i++) {
    vector<int> &po = poner[i];
    for (int jj = 0; jj < int(po.size()); jj++) insertar(po[jj], 1);
    map<int, int> &mapa = filmas[i];
    map<int, int>::iterator it = mapa.begin();
    if (it != mapa.end()) {
      int pos = it->first;
      it++;
      while (it != mapa.end()) {
        int nextpos = it->first;
        if (it->second) sol -= cuantosentre(pos + 2, nextpos - 2);
        pos = nextpos;
        it++;
      }
    }
    vector<int> &qi = poner[i];
    for (int jj = 0; jj < int(qi.size()); jj++) insertar(qi[jj], 0);
  }
  cout << sol << endl;
}