ICPC World Finals Day 5

Mr. Tee got lost in the city of R country. The trouble is that the streets are similar, so I have no idea where I am now. Country R is "sorry", so you have to return to the hotel before being attacked by the enemy. Fortunately, I only remember how it turned, so let's go random.

problem

\\ (w \ times h \\) There is a two-dimensional grid-like map of squares. Let the coordinates of the upper left cell be \\ ((1, 1) \\) and the coordinates of the lower right cell be \\ ((w, h) \\). The map is surrounded by walls, and \\ (n \\) obstacles are coordinated \\ ((x_ {i}, y_ {i}) (1 \ leq i \ leq n) \\) Is placed in. In addition, the instruction sequence \\ (r_ {1} r_ {2} \ cdots r_ {m} \\) and the target coordinates \\ ((g_ {x}, g_ {y}) \\) are given. After setting the start coordinates and the direction of travel, the pedestrian starts walking according to the following movement rules.

1. Initialize the counter to \\ (i = 1 \\) and set the start coordinates and travel direction (up / down / left / right).
2. Go straight until you meet a wall / obstacle.
3. Do one of the following in front of the wall / obstacle.
3. a. \\ (i> m \\), that is, end walking if there is no command.
3. b. If the command \\ (r_ {i} \\) is L, turn left, and if R, turn right.
4. Increment \\ (i \\).
5. Return to 2.

If the coordinates (including the start coordinates) passed from the start of walking to the end of walking include the target coordinates \\ ((g_ {x}, g_ {y}) \\), the pedestrian has reached the destination. Interpret as. Find out how many combinations of start coordinates and travel directions can reach your destination. However, it is assumed that obstacles and coordinates outside the map cannot be set as the start coordinates. (The target coordinates can be set.)

input


w h gx gy n
x1 y1
...
xn yn
r1r2… rm


Map width \\ (w \\), height \\ (h \\), destination x coordinate \\ (g_ {x} \\), destination y coordinate \\ (g_) on the first line {y} \\), the number of obstacles \\ (n \\) are given separated by blanks. From the second line to the \\ (n + 1 \\) line, the coordinates of each obstacle \\ ((x_ {i}, y_ {i}) \\) are given separated by blanks. The instruction column \\ (r_ {1} r_ {2} \ cdots r_ {m} \\) of length \\ (m \\) is given in the \\ (n + 2 \\) line.

output

Output the number of combinations of starting coordinates and traveling directions on one line so that you can reach your destination.

Constraint

* All inputs are integers
* \\ (2 \ leq w, h \ leq 10 ^ {5} (= 100000) \\)
* \\ (0 \ leq n \ leq 10 ^ {5} (= 100000) \\)
* \\ (1 \ leq g_ {x}, x_ {i} \ leq w \\)
* \\ (1 \ leq g_ {y}, y_ {i} \ leq h \\)
* \\ ((x_ {i}, y_ {i}) \ not = (g_ {x}, g_ {y}) (1 \ leq i \ leq n) \\)
* \\ ((x_ {i}, y_ {i}) \ not = (x_ {j}, y_ {j}) (i \ not = j) \\)
* \\ (r_ {i} \ in \\ {L, R \\} (1 \ leq i \ leq m) \\)
* \\ (1 \ leq m \ leq 20 \\)



Input / output example

Input 1


3 3 3 2 2
1 1
twenty two
RL


Output 1


9


In addition to the following 5 types of walking, walking (4 types) starting from the target coordinates passes through the target coordinates.

http://k-operafan.info/static/uecpc2013/files/lost_sample_1.png

Input 2


4 4 3 1 4
1 1
3 2
13
4 3
RR


Output 2


13


Walking starting from the following start coordinates / traveling direction passes through the target coordinates.

http://k-operafan.info/static/uecpc2013/files/lost_sample_2.png

Input 3


100000 100000 46597 49716 17
38713 77141
46598 78075
66177 49715
58569 77142
48303 12742
32829 65105
32830 78076
70273 27408
48302 21196
27119 54458
38714 65104
46598 54457
27118 12743
60242 21197
60241 1101
58568 27409
93581 1100
LLRRLLLLRRLL


Output 3


647505






Example

Input

w h g


Output

9
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef long long lli;

typedef pair<lli, lli> P;

const lli MAX = 100000;

lli w, h, gx, gy, n;
vector<P> input;
vector<lli> vec[4][MAX+1]; //(x, y)
string r;

bool check(lli x, lli y, lli d){
  bool f = false;
  for(lli i=0;i<=r.size();i++){
    lli nx, ny;
    if(d == 0){
      nx = x;
      ny = *(lower_bound(vec[0][x].begin(), vec[0][x].end(), -y));
      ny = -ny;
      if(nx == gx && ny == gy) return true;
      ny = ny + 1;
      if(nx == gx && ny <= gy && gy <= y) return true;

    }
    if(d == 1){
      nx = *(lower_bound(vec[1][y].begin(), vec[1][y].end(), x));
      ny = y;
      if(nx == gx && ny == gy) return true;
      nx = nx - 1;
      if(x <= gx && gx <= nx && ny == gy) return true;
    }
    if(d == 2){
      nx = x;
      ny = *(lower_bound(vec[2][x].begin(), vec[2][x].end(), y));
      if(nx == gx && ny == gy) return true;
      ny = ny - 1;
      if(nx == gx && y <= gy && gy <= ny) return true;
    }
    if(d == 3){
      nx = *(lower_bound(vec[3][y].begin(), vec[3][y].end(), -x));
      ny = y;
      nx = -nx;
      if(nx == gx && ny == gy) return true;
      nx = nx + 1;
      if(nx <= gx && gx <= x && ny == gy) return true;
    }
    x = nx;
    y = ny;
    if(i == r.size()) break;
    if(r[i] == 'R') d = (d + 1) % 4;
    else d = (d - 1 + 4) % 4;
  }
  return false;
}

lli solve(){
  lli res = 0;
  for(lli i=0;i<=MAX;i++){
    for(int j=0;j<4;j++) vec[j][i].clear();
  }
  for(lli i=0;i<input.size();i++){
    vec[1][input[i].second].push_back(input[i].first);
    vec[3][input[i].second].push_back(input[i].first);
  }
  vec[1][gy].push_back(gx);
  vec[3][gy].push_back(gx);
  for(lli i=0;i<input.size();i++){
    vec[0][input[i].first].push_back(input[i].second);
    vec[2][input[i].first].push_back(input[i].second);
  }
  vec[0][gx].push_back(gy);
  vec[2][gx].push_back(gy);
  for(lli i=0;i<4;i++){
    for(lli j=1;j<=MAX;j++){
      vec[i][j].push_back(0);
      vec[i][j].push_back((i%2==0?h:w)+1);
    }
  }
  for(lli i=0;i<=MAX;i++){
    for(lli j=0;j<vec[0][i].size();j++){
      vec[0][i][j] = -vec[0][i][j];
    }
    for(lli j=0;j<vec[3][i].size();j++){
      vec[3][i][j] = -vec[3][i][j];
    }
  }
  for(lli i=0;i<=MAX;i++){
    for(lli j=0;j<4;j++){
      if(vec[j][i].size() > 0) sort(vec[j][i].begin(), vec[j][i].end());
    }
  }
  for(lli d=0;d<4;d++){
    lli upper = (d%2==0?w:h);
    for(lli i=1;i<=upper;i++){
      for(lli j=1;j<vec[d][i].size();j++){
        if(d % 2 == 1){
          lli sx = vec[d][i][j]-1;
          if(d == 3) sx = -sx;
          if(sx <= 0 || sx > w) continue;
          if(vec[d][i][j] - vec[d][i][j-1] - 1 > 0 && check(sx, i, d)){
            res += vec[d][i][j] - vec[d][i][j-1] - 1;
          }
        }
        if(d % 2 == 0){
          lli sy = vec[d][i][j]-1;
          if(d == 0) sy = -sy;
          if(sy <= 0 || sy > h) continue;
          if(vec[d][i][j] - vec[d][i][j-1] - 1 > 0 && check(i, sy, d)){
            res += vec[d][i][j] - vec[d][i][j-1] - 1;
          }
        }
      }
    }
  }
  return res;
}

int main(){
  cin >> w >> h >> gx >> gy >> n;
  for(lli i=0;i<n;i++){
    lli x, y;
    cin >> x >> y;
    input.push_back(P(x, y));
  }
  cin >> r;
  cout << solve() + 4 << endl;
}