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>
struct Point {
  int x, y;
  Point() : x(0), y(0) {}
  Point(int x, int y) : x(x), y(y) {}
  Point transform() const { return Point(x + y, x - y); }
  Point inverse() const { return Point(x + y >> 1, x - y >> 1); }
};
bool operator==(const Point &a, const Point &b) {
  return a.x == b.x && a.y == b.y;
}
bool operator<(const Point &a, const Point &b) {
  return a.x < b.x || (a.x == b.x && a.y < b.y);
}
int n, m;
std::vector<Point> blocks;
std::map<int, std::vector<int> > indices[2];
long long get_hash(const Point &p, const Point &d) {
  long long ret = p.x;
  ret *= m + 2;
  ret += p.y;
  ret <<= 1;
  ret += d.x + 1 >> 1;
  ret <<= 1;
  ret += d.y + 1 >> 1;
  return ret;
}
bool has_block(int x, int y) {
  return std::binary_search((blocks).begin(), (blocks).end(), Point(x, y));
}
std::set<long long> state_hashes;
const int LARGE = 1000000;
struct Event {
  int x_1, x_2, y, d;
  Event(int x_1, int x_2, int y, int d)
      : x_1(x_1), x_2(x_2), y(y + LARGE >> 1), d(d) {}
};
bool operator<(const Event &a, const Event &b) {
  return a.y < b.y || (a.y == b.y && a.d < b.d);
}
int delta[LARGE], count[LARGE];
int get_id(int l, int r) { return l + r | (l != r); }
void cover(int l, int r, int a, int b, int c) {
  if (b < l || r < a) {
    return;
  }
  int id = get_id(l, r);
  int m = l + r >> 1;
  if (a <= l && r <= b) {
    delta[id] += c;
  } else {
    cover(l, m, a, b, c);
    cover(m + 1, r, a, b, c);
  }
  count[id] = l == r ? 0 : count[get_id(l, m)] + count[get_id(m + 1, r)];
  if (delta[id]) {
    count[id] = r - l + 1;
  }
}
int main() {
  int block_count;
  scanf("%d%d%d", &n, &m, &block_count);
  for (int i = 0; i <= n + 1; ++i) {
    blocks.push_back(Point(i, 0));
    blocks.push_back(Point(i, m + 1));
  }
  for (int j = 0; j <= m + 1; ++j) {
    blocks.push_back(Point(0, j));
    blocks.push_back(Point(n + 1, j));
  }
  while (block_count--) {
    int x, y;
    scanf("%d%d", &x, &y);
    blocks.push_back(Point(x, y));
  }
  std::sort((blocks).begin(), (blocks).end());
  blocks.erase(std::unique((blocks).begin(), (blocks).end()), blocks.end());
  int s_x, s_y;
  char names[3];
  scanf("%d%d%s", &s_x, &s_y, names);
  for (__typeof((blocks).begin()) iter = (blocks).begin();
       iter != (blocks).end(); ++iter) {
    Point p(iter->transform());
    indices[0][p.x].push_back(p.y);
    indices[1][p.y].push_back(p.x);
  }
  for (int t = 0; t < 2; ++t) {
    for (__typeof((indices[t]).begin()) iter = (indices[t]).begin();
         iter != (indices[t]).end(); ++iter) {
      std::sort((iter->second).begin(), (iter->second).end());
    }
  }
  Point now(s_x, s_y);
  Point now_d(names[0] == 'S' ? 1 : -1, names[1] == 'E' ? 1 : -1);
  std::vector<Event> events[2];
  while (true) {
    long long hash = get_hash(now, now_d);
    if (state_hashes.count(hash)) {
      break;
    }
    state_hashes.insert(hash);
    Point p(now.transform());
    Point q(now_d.transform());
    int t = q.y != 0;
    if (t) {
      std::swap(p.x, p.y);
      std::swap(q.x, q.y);
    }
    std::vector<int> &v = indices[t ^ 1][p.y];
    Point r(*(q.x > 0 ? upper_bound((v).begin(), (v).end(), p.x)
                      : lower_bound((v).begin(), (v).end(), p.x) - 1) -
                q.x,
            p.y);
    if (t) {
      std::swap(p.x, p.y);
      std::swap(q.x, q.y);
      std::swap(r.x, r.y);
    }
    int o = p.x & 1;
    int a = p.x >> 1;
    int b = r.x >> 1;
    if (a > b) {
      std::swap(a, b);
    }
    events[o].push_back(Event(a, b, std::max(p.y, r.y), -1));
    events[o].push_back(Event(a, b, std::min(p.y, r.y) - 2, 1));
    now = r.inverse();
    bool hx = has_block(now.x + now_d.x, now.y);
    bool hy = has_block(now.x, now.y + now_d.y);
    if (hx ^ hy) {
      if (hx) {
        now_d.x *= -1;
        now.y += now_d.y;
      } else {
        now_d.y *= -1;
        now.x += now_d.x;
      }
    } else {
      now_d.x *= -1;
      now_d.y *= -1;
    }
  }
  long long answer = 0;
  for (int t = 0; t < 2; ++t) {
    int max = std::max(n, m);
    memset(delta, 0, sizeof(delta));
    memset(count, 0, sizeof(count));
    std::sort((events[t]).begin(), (events[t]).end());
    for (int i = 0; i < (int)events[t].size(); ++i) {
      Event &e = events[t][i];
      if (i) {
        answer += (long long)count[get_id(0, max)] * (e.y - events[t][i - 1].y);
      }
      cover(0, max, e.x_1, e.x_2, e.d);
    }
  }
  std::cout << answer << std::endl;
  return 0;
}