Problem: Steve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are n shields in total, the i-th shield is located at point (xi, yi) of the coordinate plane. It's possible that two or more shields share the same location.

Steve wants to paint all these shields. He paints each shield in either red or blue. Painting a shield in red costs r dollars while painting it in blue costs b dollars.

Additionally, there are m constraints Steve wants to be satisfied. The i-th constraint is provided by three integers ti, li and di:

  * If ti = 1, then the absolute difference between the number of red and blue shields on line x = li should not exceed di. 
  * If ti = 2, then the absolute difference between the number of red and blue shields on line y = li should not exceed di. 



Steve gave you the task of finding the painting that satisfies all the condition and the total cost is minimum.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the number of shields and the number of constraints respectively.

The second line contains two integers r and b (1 ≤ r, b ≤ 109).

The next n lines contain the shields coordinates. The i-th of these lines contains two integers xi and yi (1 ≤ xi, yi ≤ 109).

The next m lines contain the constrains. The j-th of these lines contains three integers tj, lj and dj (1 ≤ tj ≤ 2, 1 ≤ lj ≤ 109, 0 ≤ dj ≤ n).

Output

If satisfying all the constraints is impossible print -1 in first and only line of the output.

Otherwise, print the minimum total cost in the first line of output. In the second line print a string of length n consisting of letters 'r' and 'b' only. The i-th character should be 'r' if the i-th shield should be painted red in the optimal answer and 'b' if it should be painted blue. The cost of painting shields in these colors should be equal the minimum cost you printed on the first line.

If there exist more than one optimal solution, print any of them.

Examples

Input

5 6
8 3
2 10
1 5
9 10
9 10
2 8
1 9 1
1 2 1
2 10 3
2 10 2
1 1 1
2 5 2


Output

25
rbrbb


Input

4 4
7 3
10 3
9 8
10 3
2 8
2 8 0
2 8 0
1 2 0
1 9 0


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 6, inf = 0x3f3f3f3f;
inline void failed() {
  cout << "-1\n";
  exit(0);
}
int n, m, Red, Blue, nod, head[N], cnt = 1, dlt[N], X[N], Y[N], iter[N];
int Lx[N], Ly[N], Rx[N], Ry[N], Dx[N], Dy[N];
int degX[N], degY[N];
int S, T, TT;
int Id[N];
long long dis[N];
bool vis[N];
vector<int> vX, vY;
long long ans;
struct edge {
  int to, nxt, cap, cost;
} e[N << 2];
inline int addedge(int u, int v, int cap, int cost) {
  e[++cnt] = (edge){v, head[u], cap, cost}, head[u] = cnt;
  e[++cnt] = (edge){u, head[v], 0, -cost}, head[v] = cnt;
  return cnt - 1;
}
inline void AddEdgE(int u, int v, int L, int R, int cost) {
  ans += (long long)cost * L, dlt[u] -= L, dlt[v] += L;
  addedge(u, v, R - L, cost);
}
int q[1048576];
int dfs(int u, int f) {
  if (u == TT || !f) return f;
  vis[u] = 1;
  int ret = 0;
  for (int& i = iter[u]; i; i = e[i].nxt)
    if (e[i].cap && !vis[e[i].to] && dis[e[i].to] == dis[u] + e[i].cost) {
      int d = dfs(e[i].to, min(f, e[i].cap));
      e[i].cap -= d, e[i ^ 1].cap += d, f -= d, ret += d;
      if (!f) break;
    }
  vis[u] = 0;
  return ret;
}
bool MCMF() {
  memset(dis, 0x3f, sizeof dis);
  dis[0] = 0;
  int h = 0, t = 1;
  q[0] = 0;
  while (h != t) {
    int u = q[h++];
    h &= 1048575;
    vis[u] = 0;
    for (int i = head[u]; i; i = e[i].nxt)
      if (e[i].cap && dis[e[i].to] > dis[u] + e[i].cost) {
        dis[e[i].to] = dis[u] + e[i].cost;
        if (!vis[e[i].to]) {
          vis[e[i].to] = 1;
          q[t++] = e[i].to;
          t &= 1048575;
        }
      }
  }
  if (dis[TT] > 1e18) return 0;
  memcpy(iter, head, sizeof head);
  ans += dfs(0, inf) * dis[TT];
  return 1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> Red >> Blue;
  bool tag = 0;
  if (Red > Blue) swap(Red, Blue), tag = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> X[i] >> Y[i];
    vX.push_back(X[i]);
    vY.push_back(Y[i]);
  }
  sort(vX.begin(), vX.end());
  sort(vY.begin(), vY.end());
  vX.erase(unique(vX.begin(), vX.end()), vX.end());
  vY.erase(unique(vY.begin(), vY.end()), vY.end());
  for (int i = 0; i < vX.size(); ++i) Lx[i] = ++nod, Rx[i] = ++nod;
  for (int i = 0; i < vY.size(); ++i) Ly[i] = ++nod, Ry[i] = ++nod;
  S = ++nod, T = ++nod, TT = ++nod;
  memset(Dx, 0x3f, sizeof Dx);
  memset(Dy, 0x3f, sizeof Dy);
  while (m--) {
    int t, x, d;
    cin >> t >> x >> d;
    if (t == 1) {
      int id = lower_bound(vX.begin(), vX.end(), x) - vX.begin();
      if (id < vX.size() && vX[id] == x) Dx[id] = min(Dx[id], d);
    } else {
      int id = lower_bound(vY.begin(), vY.end(), x) - vY.begin();
      if (id < vY.size() && vY[id] == x) Dy[id] = min(Dy[id], d);
    }
  }
  ans = (long long)Red * n;
  for (int i = 1; i <= n; ++i) {
    int x = lower_bound(vX.begin(), vX.end(), X[i]) - vX.begin();
    int y = lower_bound(vY.begin(), vY.end(), Y[i]) - vY.begin();
    Id[i] = addedge(Rx[x], Ly[y], 1, Blue - Red);
    ++degX[x], ++degY[y];
  }
  for (int i = 0; i < vX.size(); ++i) {
    addedge(S, Lx[i], n, 0);
    if (Dx[i] > 1e9) {
      addedge(Lx[i], Rx[i], n, 0);
      continue;
    }
    int L = (degX[i] - Dx[i] + 1) / 2, R = (degX[i] + Dx[i]) / 2;
    if (L > R) failed();
    AddEdgE(Lx[i], Rx[i], L, R, 0);
  }
  for (int i = 0; i < vY.size(); ++i) {
    addedge(Ry[i], T, n, 0);
    if (Dy[i] > 1e9) {
      addedge(Ly[i], Ry[i], n, 0);
      continue;
    }
    int L = (degY[i] - Dy[i] + 1) / 2, R = (degY[i] + Dy[i]) / 2;
    if (L > R) failed();
    AddEdgE(Ly[i], Ry[i], L, R, 0);
  }
  addedge(T, S, inf, 0);
  for (int i = 1; i <= T; ++i)
    if (dlt[i] > 0)
      addedge(0, i, dlt[i], 0);
    else if (dlt[i] < 0)
      addedge(i, TT, -dlt[i], 0);
  while (MCMF())
    ;
  for (int i = head[0]; i; i = e[i].nxt)
    if (e[i].cap) failed();
  cout << ans << '\n';
  for (int i = 1; i <= n; ++i)
    if (e[Id[i]].cap ^ tag)
      cout.put('r');
    else
      cout.put('b');
  cout << '\n';
  return 0;
}