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;
struct edge {
  int to, nxt, f;
} e[2000006];
int n, m, cnt = 1, r, b;
int fir[200005], x[200005], y[200005], numx[200005], numy[200005], delx[200005],
    dely[200005], dis[200005], cur[200005], p[200005];
map<int, int> mx, my;
void add(int, int, int);
int Dinic(int, int);
int dfs(int, int, int);
bool bfs(int, int);
int main() {
  scanf("%d%d%d%d", &n, &m, &r, &b);
  bool flag = false;
  if (r > b) swap(r, b), flag = true;
  int totx = 0, toty = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", x + i, y + i);
    if (!mx.count(x[i])) mx[x[i]] = ++totx;
    if (!my.count(y[i])) my[y[i]] = ++toty;
    ++numx[mx[x[i]]];
    ++numy[my[y[i]]];
  }
  int tot = totx + toty, eS = tot + 1, eT = tot + 2, S = tot + 3, T = tot + 4;
  for (int i = 1; i <= n; ++i) delx[i] = dely[i] = n;
  for (int i = 1; i <= m; ++i) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      if (!mx.count(l)) continue;
      delx[mx[l]] = min(delx[mx[l]], d);
    } else {
      if (!my.count(l)) continue;
      dely[my[l]] = min(dely[my[l]], d);
    }
  }
  int sum = 0;
  for (int i = 1; i <= totx; ++i) {
    int l = max(0, (numx[i] - delx[i] + 1) / 2);
    int r = min(numx[i], (numx[i] + delx[i]) / 2);
    if (l > r) return puts("-1"), 0;
    add(eS, i, l);
    add(S, eT, l);
    add(S, i, r - l);
    sum += l;
  }
  for (int i = 1; i <= toty; ++i) {
    int l = max(0, (numy[i] - dely[i] + 1) / 2);
    int r = min(numy[i], (numy[i] + dely[i]) / 2);
    if (l > r) return puts("-1"), 0;
    add(i + totx, eT, l);
    add(eS, T, l);
    add(i + totx, T, r - l);
    sum += l;
  }
  for (int i = 1; i <= n; ++i) {
    int nx = mx[x[i]], ny = my[y[i]];
    p[i] = cnt + 1;
    add(nx, ny + totx, 1);
  }
  add(T, S, 999999999);
  int tmp = Dinic(eS, eT);
  if (tmp != sum) return puts("-1"), 0;
  tmp = Dinic(S, T);
  cout << 1ll * tmp * r + 1ll * (n - tmp) * b << endl;
  for (int i = 1; i <= n; ++i) putchar(e[p[i]].f ^ flag ? 'b' : 'r');
  return 0;
}
void add(int u, int v, int f) {
  if (!f) return;
  e[++cnt] = (edge){v, fir[u], f};
  fir[u] = cnt;
  e[++cnt] = (edge){u, fir[v], 0};
  fir[v] = cnt;
  return;
}
int Dinic(int S, int T) {
  int sum = 0;
  while (bfs(S, T))
    while (int d = dfs(S, T, 999999999)) sum += d;
  return sum;
}
bool bfs(int S, int T) {
  memset(dis, -1, sizeof dis);
  memcpy(cur, fir, sizeof cur);
  queue<int> Q;
  dis[S] = 0;
  Q.push(S);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = fir[u]; i; i = e[i].nxt) {
      int v = e[i].to, f = e[i].f;
      if (!f || dis[v] != -1) continue;
      dis[v] = dis[u] + 1;
      Q.push(v);
    }
  }
  return dis[T] != -1;
}
int dfs(int u, int T, int flow) {
  if (u == T) return flow;
  int sum = 0;
  for (int &i = cur[u]; i; i = e[i].nxt) {
    int v = e[i].to, f = min(flow, e[i].f);
    if (dis[v] != dis[u] + 1 || !e[i].f) continue;
    int d = dfs(v, T, f);
    if (!d) continue;
    sum += d;
    flow -= d;
    e[i].f -= d;
    e[i ^ 1].f += d;
    if (!flow) break;
  }
  if (!sum) dis[u] = -1;
  return sum;
}