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 inf = 0x7FFFFFFF;
struct Point {
  int x, y;
} P[100000 + 10], tp1[100000 + 10], tp2[100000 + 10];
map<int, int> from[2];
bool flag = 0, bz[1000000 + 10];
int Node[2 * 1000000 + 10], Next[2 * 1000000 + 10], C[2 * 1000000 + 10],
    Head[1000000 + 10], tot = 1;
int vh[1000000 + 10], h[1000000 + 10], di[1000000 + 10], Rec[2 * 1000000 + 10];
int Q[1000000 + 10], E[1000000 + 10], ans[100000 + 10];
int n, m, r, b;
int S, T, SS, TT;
int MaxFlow, num;
bool cmp(Point a, Point b) { return a.x < b.x; }
void link(int u, int v, int w) {
  Node[++tot] = v, Next[tot] = Head[u], C[tot] = w, Head[u] = tot;
  Node[++tot] = u, Next[tot] = Head[v], C[tot] = 0, Head[v] = tot;
}
int SAP(int x, int aug) {
  int use = 0;
  if (x == T) return aug;
  for (int p = di[x]; p; p = Next[p]) {
    if (h[x] != h[Node[p]] + 1 || !C[p] || bz[Node[p]]) continue;
    di[x] = p;
    int ret = SAP(Node[p], min(aug - use, C[p]));
    C[p] -= ret;
    C[p ^ 1] += ret;
    use += ret;
    if (h[S] > num || aug == use) return use;
  }
  if (--vh[h[x]] == 0) {
    h[S] = num + 1;
    return use;
  }
  h[x]++;
  vh[h[x]]++;
  di[x] = Head[x];
  return use;
}
void Flow(int u, int v) {
  S = u, T = v;
  memset(h, 0, sizeof(h));
  memset(vh, 0, sizeof(vh));
  memcpy(di, Head, sizeof(di));
  vh[0] = num;
  while (h[S] <= num) MaxFlow += SAP(S, inf);
  S = 0, T = num - 3;
}
bool Impossible() {
  for (int p = Head[SS]; p; p = Next[p]) {
    if (C[p]) return 1;
    C[p] = C[p ^ 1] = 0;
  }
  for (int p = Head[TT]; p; p = Next[p]) C[p] = C[p ^ 1] = 0;
  for (int p = Head[S]; p; p = Next[p])
    if (Node[p] == T) C[p] = C[p ^ 1] = 0;
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &P[i].x, &P[i].y);
    tp1[i].x = P[i].x, tp2[i].x = P[i].y;
    tp1[i].y = tp2[i].y = i;
  }
  sort(tp1 + 1, tp1 + n + 1, cmp);
  sort(tp2 + 1, tp2 + n + 1, cmp);
  int Cnt1 = 0, Cnt2 = 0;
  for (int i = 1; i <= n; i++) {
    if (tp1[i].x != tp1[i - 1].x) Cnt1++;
    from[0][P[tp1[i].y].x] = Cnt1;
    P[tp1[i].y].x = Cnt1;
  }
  for (int i = 1; i <= n; i++) {
    if (tp2[i].x != tp2[i - 1].x) Cnt2++;
    from[1][P[tp2[i].y].y] = Cnt2;
    P[tp2[i].y].y = Cnt2;
  }
  S = 0, T = Cnt1 + Cnt2 + 1;
  SS = T + 1, TT = T + 2, num = TT + 1;
  for (int i = 1; i <= n; i++) {
    link(P[i].x, Cnt1 + P[i].y, 1);
    Q[P[i].x]++, Q[Cnt1 + P[i].y]++;
    Rec[tot - 1] = i;
  }
  memset(E, 63, sizeof(E));
  for (int i = 1; i <= m; i++) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    if (from[t - 1].find(l) == from[t - 1].end()) continue;
    l = from[t - 1][l] + (t - 1) * Cnt1;
    E[l] = min(E[l], d);
  }
  for (int i = 1; i < T; i++) {
    E[i] = min(E[i], Q[i]);
    int L = (Q[i] - E[i]) / 2 + (Q[i] - E[i]) % 2;
    int R = (Q[i] + E[i]) / 2;
    if (L > R) {
      printf("-1\n");
      return 0;
    }
    if (i <= Cnt1) {
      link(SS, i, L);
      link(S, TT, L);
      link(S, i, R - L);
    } else {
      link(SS, T, L);
      link(i, TT, L);
      link(i, T, R - L);
    }
  }
  link(T, S, inf);
  Flow(SS, TT);
  MaxFlow = C[Head[S]];
  if (Impossible()) {
    printf("-1\n");
    return 0;
  }
  bz[SS] = bz[TT] = 1;
  Flow(S, T);
  if (r > b) swap(r, b), flag = 1;
  printf("%I64d\n", (long long)MaxFlow * r + (long long)(n - MaxFlow) * b);
  for (int i = 1; i <= Cnt1; i++) {
    for (int p = Head[i]; p; p = Next[p]) {
      if (!Rec[p]) continue;
      if (!C[p])
        ans[Rec[p]] = flag;
      else
        ans[Rec[p]] = !flag;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == 0)
      printf("r");
    else
      printf("b");
  }
  return 0;
}