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 NN = 100010;
const int N = 200010;
const int M = N * 10;
const int INF = 0x3f3f3f3f;
struct Node {
  int v, c;
  Node *nxt, *tw;
} * g[N], *Cur[N], pool[M], *tail = pool, nonsense;
int n, m, r, b, S, T, SS, TT, pc;
int x[NN], y[NN], xx[NN], yy[NN], xc, yc;
int cntx[NN], cnty[NN], mx[NN], my[NN], ss[N];
int d[N];
inline int ckmin(int &a, int b) { return b < a ? a = b, 1 : 0; }
inline void make_edge(int u, int v, int c) {
  tail->v = v;
  tail->c = c;
  tail->nxt = g[u];
  tail->tw = tail + 1;
  g[u] = tail++;
  tail->v = u;
  tail->c = 0;
  tail->nxt = g[v];
  tail->tw = tail - 1;
  g[v] = tail++;
}
int bfs(int S, int T) {
  static int q[N], l, r;
  memset(d, 0, sizeof(d));
  d[S] = 1;
  for (int i = 1; i <= TT; i++) Cur[i] = &nonsense;
  for (q[l = r = 0] = S; l <= r; l++)
    for (Node *p = g[q[l]]; p; p = p->nxt)
      if (p->c && !d[p->v]) d[q[++r] = p->v] = d[q[l]] + 1;
  return d[T];
}
int dfs(int u, int cur, int T) {
  int cc = cur;
  if (u == T) return cur;
  if (Cur[u] == &nonsense) Cur[u] = g[u];
  for (Node *&p = Cur[u]; p; p = p->nxt)
    if (p->c && d[p->v] == d[u] + 1) {
      int t = dfs(p->v, min(cc, p->c), T);
      p->c -= t;
      p->tw->c += t;
      cc -= t;
      if (!cc) break;
    }
  return cur - cc;
}
int dinic(int S, int T) {
  int res = 0;
  while (bfs(S, T)) res += dfs(S, INF, T);
  return res;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &r, &b);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &x[i], &y[i]), xx[i] = x[i], yy[i] = y[i];
  sort(xx + 1, xx + n + 1);
  xc = unique(xx + 1, xx + n + 1) - xx - 1;
  sort(yy + 1, yy + n + 1);
  yc = unique(yy + 1, yy + n + 1) - yy - 1;
  pc = xc + yc;
  S = ++pc;
  T = ++pc;
  SS = ++pc;
  TT = ++pc;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(xx + 1, xx + xc + 1, x[i]) - xx;
    cntx[x[i]]++;
    y[i] = lower_bound(yy + 1, yy + yc + 1, y[i]) - yy;
    cnty[y[i]]++;
    make_edge(x[i], y[i] + xc, 1);
  }
  for (int i = 1; i <= xc; i++) mx[i] = cntx[i];
  for (int i = 1; i <= yc; i++) my[i] = cnty[i];
  for (int i = 1, t, l, d, td; i <= m; i++) {
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      td = lower_bound(xx + 1, xx + xc + 1, l) - xx;
      if (td <= xc && xx[td] == l) ckmin(mx[td], d);
    } else {
      td = lower_bound(yy + 1, yy + yc + 1, l) - yy;
      if (td <= yc && yy[td] == l) ckmin(my[td], d);
    }
  }
  for (int i = 1; i <= xc; i++) {
    int l = (cntx[i] - mx[i] + 1) >> 1, r = (cntx[i] + mx[i]) >> 1;
    if (l > r) return puts("-1"), 0;
    make_edge(S, i, r - l);
    ss[S] += l;
    ss[i] -= l;
  }
  for (int i = 1; i <= yc; i++) {
    int l = (cnty[i] - my[i] + 1) >> 1, r = (cnty[i] + my[i]) >> 1;
    if (l > r) return puts("-1"), 0;
    make_edge(i + xc, T, r - l);
    ss[i + xc] += l;
    ss[T] -= l;
  }
  int sum = 0;
  for (int i = 1; i <= T; i++)
    if (ss[i] > 0)
      make_edge(i, TT, ss[i]), sum += ss[i];
    else
      make_edge(SS, i, -ss[i]);
  make_edge(T, S, INF);
  int ans = dinic(SS, TT);
  if (ans < sum) return puts("-1"), 0;
  ans = dinic(S, T);
  printf("%I64d\n", 1ll * ans * min(r, b) + 1ll * (n - ans) * max(r, b));
  for (int i = 0; i < 2 * n; i += 2) putchar("rb"[pool[i].c xor r > b]);
  return 0;
}