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;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, tag, s, t, S, T;
int R, B;
long long sum, ans, com;
int a[100010], b[100010], top1, top2;
int lima[100010], limb[100010], upa[100010], upb[100010], lowa[100010],
    lowb[100010];
int cnta[100010], cntb[100010];
struct P {
  int x, y;
} p[100010];
int deg[100010 * 2];
int head[100010 * 2], to[500010 * 2], nxt[500010 * 2], c[500010 * 2],
    v[500010 * 2], tot = 1;
int id[500010 * 2];
void add(int x, int y, int z, int h, int idx) {
  tot++;
  nxt[tot] = head[x];
  head[x] = tot;
  to[tot] = y;
  c[tot] = z;
  v[tot] = h;
  id[tot] = idx;
}
void work(int x, int y, int z, int h, int c, int idx) {
  deg[y] += z;
  deg[x] -= z;
  add(x, y, h - z, c, idx);
  add(y, x, 0, -c, idx);
}
int dep[100010 * 2], cur[100010 * 2];
queue<int> q;
void bfs() {
  for (int i = 1; i <= T; i++) dep[i] = -1;
  dep[S] = 0;
  q.push(S);
  while (q.size()) {
    int now = q.front();
    q.pop();
    for (int i = head[now]; i; i = nxt[i]) {
      if (dep[to[i]] < 0 && c[i]) {
        dep[to[i]] = dep[now] + 1;
        q.push(to[i]);
      }
    }
  }
}
int dfs(int u, int y, int dist) {
  if (u == y) return dist;
  for (int &i = cur[u]; i; i = nxt[i]) {
    if (dep[to[i]] == dep[u] + 1 && c[i]) {
      int di = dfs(to[i], y, min(dist, c[i]));
      if (di) {
        c[i] -= di;
        c[i ^ 1] += di;
        ans += 1ll * v[i] * di;
        return di;
      }
    }
  }
  return 0;
}
void Dinic() {
  while (true) {
    bfs();
    if (dep[T] < 0) return;
    for (int i = 1; i <= T; i++) cur[i] = head[i];
    while (int d = dfs(S, T, 1000000007)) {
      com += d;
    }
  }
}
int ansx[100010];
int main() {
  n = read();
  m = read();
  R = read();
  B = read();
  if (R > B) swap(R, B), tag = 1;
  for (int i = 1; i <= n; i++) p[i].x = read(), p[i].y = read();
  for (int i = 1; i <= n; i++) a[++top1] = p[i].x, b[++top2] = p[i].y;
  a[++top1] = 1e9 + 1;
  b[++top2] = 1e9 + 1;
  sort(a + 1, a + top1 + 1);
  sort(b + 1, b + top2 + 1);
  top1 = unique(a + 1, a + top1 + 1) - a - 1;
  top2 = unique(b + 1, b + top2 + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    p[i].x = lower_bound(a + 1, a + top1 + 1, p[i].x) - a;
    p[i].y = lower_bound(b + 1, b + top2 + 1, p[i].y) - b;
  }
  for (int i = 1; i <= top1; i++) lima[i] = 1000000007;
  for (int i = 1; i <= top2; i++) limb[i] = 1000000007;
  for (int i = 1; i <= m; i++) {
    int t = read(), l = read(), d = read();
    if (t == 1) {
      int pos = lower_bound(a + 1, a + top1 + 1, l) - a;
      if (a[pos] == l) {
        lima[pos] = min(lima[pos], d);
      }
    } else {
      int pos = lower_bound(b + 1, b + top2 + 1, l) - b;
      if (b[pos] == l) {
        limb[pos] = min(limb[pos], d);
      }
    }
  }
  for (int i = 1; i <= n; i++) cnta[p[i].x]++, cntb[p[i].y]++;
  for (int i = 1; i <= top1; i++) {
    if (lima[i] == 1000000007) {
      upa[i] = 1000000007;
      lowa[i] = 0;
    } else {
      if (!lima[i] && cnta[i] & 1) {
        puts("-1");
        return 0;
      }
      upa[i] = (cnta[i] + lima[i]) / 2;
      lowa[i] = max(0, (cnta[i] - lima[i] + 1) / 2);
    }
  }
  for (int i = 1; i <= top2; i++) {
    if (limb[i] == 1000000007) {
      upb[i] = 1000000007;
      lowb[i] = 0;
    } else {
      if (!limb[i] && cntb[i] & 1) {
        puts("-1");
        return 0;
      }
      upb[i] = (cntb[i] + limb[i]) / 2;
      lowb[i] = max(0, (cntb[i] - limb[i] + 1) / 2);
    }
  }
  s = top1 + top2 + 1;
  t = top1 + top2 + 2;
  S = top1 + top2 + 3;
  T = top1 + top2 + 4;
  for (int i = 1; i <= top1; i++) work(s, i, lowa[i], upa[i], 0, 0);
  for (int i = 1; i <= top2; i++) work(i + top1, t, lowb[i], upb[i], 0, 0);
  for (int i = 1; i <= n; i++) work(p[i].x, top1 + p[i].y, 0, 1, B - R, i);
  for (int i = 1; i <= top1 + top2 + 2; i++) {
    if (deg[i] > 0)
      add(S, i, deg[i], 0, 0), add(i, S, 0, 0, 0), sum += deg[i];
    else
      add(i, T, -deg[i], 0, 0);
    add(T, i, 0, 0, 0);
  }
  Dinic();
  work(t, s, 0, 1000000007, 0, 0);
  Dinic();
  if (com != sum) {
    puts("-1");
    return 0;
  }
  printf("%lld\n", ans + 1ll * n * R);
  for (int i = 1; i <= top1; i++) {
    for (int j = head[i]; j; j = nxt[j]) {
      if (!id[j]) continue;
      ansx[id[j]] = c[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ansx[i]) {
      if (tag)
        printf("b");
      else
        printf("r");
    } else {
      if (tag)
        printf("r");
      else
        printf("b");
    }
  }
  return 0;
}