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 MAXN = 1e6;
const int MAXM = 1e6;
const int inf = 1 << 30;
int n, m, cnt, S, T, in[MAXN], out[MAXN], cur[MAXN], d[MAXN];
vector<int> Eid[MAXN];
struct Edge {
  int c, v;
} E[MAXM];
void AddEdge(int x, int y, int c) {
  if (c == 0) return;
  E[++cnt].v = y, E[cnt].c = c;
  Eid[x].push_back(cnt);
  E[++cnt].v = x, E[cnt].c = 0;
  Eid[y].push_back(cnt);
}
bool BFS() {
  static int Q[MAXN];
  int x, i, ql, qr;
  for (i = 0; i <= T + 4; i++) d[i] = -1;
  Q[ql = qr = 0] = S;
  d[S] = 0;
  while (ql <= qr) {
    x = Q[ql++];
    for (i = 0; i < Eid[x].size(); i++) {
      const Edge &e = E[Eid[x][i]];
      if (e.c && d[e.v] == -1) {
        Q[++qr] = e.v;
        d[e.v] = d[x] + 1;
        if (e.v == T) return 1;
      }
    }
  }
  return 0;
}
int Aug(int x, int a) {
  if (x == T) return a;
  int aug = 0, delta;
  for (int &i = cur[x]; i < Eid[x].size(); i++) {
    Edge &e = E[Eid[x][i]];
    if (e.c && d[e.v] == d[x] + 1) {
      delta = Aug(e.v, min(a, e.c));
      if (delta) {
        e.c -= delta;
        E[Eid[x][i] ^ 1].c += delta;
        aug += delta;
        if (!(a -= delta)) break;
      }
    }
  }
  if (!aug) d[x] = -1;
  return aug;
}
int MaxFlow() {
  int flow = 0;
  while (BFS()) {
    for (int i = 0; i <= T + 4; i++) cur[i] = 0;
    flow += Aug(S, inf);
  }
  return flow;
}
int r, b, t1, t2, X[MAXN], Y[MAXN], t[MAXN], l[MAXN], D[MAXN], dx[MAXN],
    dy[MAXN];
int x[MAXN], y[MAXN], sumx[MAXN], sumy[MAXN], eid[MAXN];
bool bo[MAXN];
long long ans;
int main() {
  cnt = -1;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", x + i, y + i);
    X[++t1] = x[i];
    Y[++t2] = y[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", t + i, l + i, D + i);
    if (t[i] == 1)
      X[++t1] = l[i];
    else
      Y[++t2] = l[i];
  }
  sort(X + 1, X + 1 + t1);
  t1 = unique(X + 1, X + 1 + t1) - X - 1;
  sort(Y + 1, Y + 1 + t2);
  t2 = unique(Y + 1, Y + 1 + t2) - Y - 1;
  memset(dx, 0x3f, sizeof(dx));
  memset(dy, 0x3f, sizeof(dy));
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(X + 1, X + 1 + t1, x[i]) - X;
    y[i] = lower_bound(Y + 1, Y + 1 + t2, y[i]) - Y;
    sumx[x[i]]++;
    sumy[y[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    if (t[i] == 1) {
      l[i] = lower_bound(X + 1, X + 1 + t1, l[i]) - X;
      dx[l[i]] = min(dx[l[i]], D[i]);
    } else {
      l[i] = lower_bound(Y + 1, Y + 1 + t2, l[i]) - Y;
      dy[l[i]] = min(dy[l[i]], D[i]);
    }
  }
  for (int i = 1; i <= n; i++) AddEdge(x[i], t1 + y[i], 1), eid[i] = cnt;
  for (int i = 1; i <= m; i++) {
    int L, R;
    if (t[i] == 1) {
      if (dx[l[i]] < 0) continue;
      L = (sumx[l[i]] - dx[l[i]] + 1) / 2;
      L = max(L, 0);
      R = (sumx[l[i]] + dx[l[i]]) / 2;
      R = min(R, sumx[l[i]]);
      if (L > R) return puts("-1");
      AddEdge(t1 + t2 + 1, l[i], R - L);
      AddEdge(t1 + t2 + 3, l[i], L);
      AddEdge(t1 + t2 + 1, t1 + t2 + 4, L);
      dx[l[i]] = -1;
      ans += L;
    } else {
      if (dy[l[i]] < 0) continue;
      L = (sumy[l[i]] - dy[l[i]] + 1) / 2;
      L = max(L, 0);
      R = (sumy[l[i]] + dy[l[i]]) / 2;
      R = min(R, sumy[l[i]]);
      if (L > R) return puts("-1");
      AddEdge(t1 + l[i], t1 + t2 + 2, R - L);
      AddEdge(t1 + t2 + 3, t1 + t2 + 2, L);
      AddEdge(t1 + l[i], t1 + t2 + 4, L);
      dy[l[i]] = -1;
      ans += L;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (dx[x[i]] > 0) AddEdge(t1 + t2 + 1, x[i], sumx[x[i]]);
    if (dy[y[i]] > 0) AddEdge(t1 + y[i], t1 + t2 + 2, sumy[y[i]]);
  }
  AddEdge(t1 + t2 + 2, t1 + t2 + 1, inf);
  S = t1 + t2 + 3;
  T = t1 + t2 + 4;
  if (ans != MaxFlow()) return puts("-1");
  ans = E[cnt].c;
  E[cnt].c = 0;
  S = t1 + t2 + 1;
  T = t1 + t2 + 2;
  ans += MaxFlow();
  ans = ans * min(r, b) + (n - ans) * max(r, b);
  cout << ans << endl;
  char A, B;
  if (r < b)
    A = 'r', B = 'b';
  else
    A = 'b', B = 'r';
  for (int i = 1; i <= n; i++) {
    if (E[eid[i]].c == 1)
      putchar(A);
    else
      putchar(B);
  }
}