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 n, m, _R, _B;
int s, t, ss, tt;
struct Edge {
  int to, next, w;
} e[200010 * 10];
int c1, head[200010], id[200010 * 10];
inline void add_edge(int u, int v, int w) {
  e[c1].to = v;
  e[c1].w = w;
  e[c1].next = head[u];
  head[u] = c1++;
}
int in[200010], out[200010];
inline void Add_edge(int u, int v, int l, int r) {
  in[v] += l;
  out[u] += l;
  add_edge(u, v, r - l);
  add_edge(v, u, 0);
}
struct node {
  int l, r;
} a[200010];
int b[200010], c[200010], cnt, Cnt;
void init_hash() {
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].l, &a[i].r);
  for (int i = 1; i <= n; ++i) b[i] = a[i].l;
  sort(b + 1, b + n + 1);
  cnt = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; ++i)
    a[i].l = lower_bound(b + 1, b + cnt + 1, a[i].l) - b;
  for (int i = 1; i <= n; ++i) c[i] = a[i].r;
  sort(c + 1, c + n + 1);
  Cnt = unique(c + 1, c + n + 1) - c - 1;
  for (int i = 1; i <= n; ++i)
    a[i].r = lower_bound(c + 1, c + Cnt + 1, a[i].r) - c;
}
int A[200010], B[200010], s1[200010], s2[200010];
int Q[200010], dep[200010];
bool bfs() {
  memset(dep, 0, sizeof dep);
  dep[s] = 1;
  int _h = 0, _t = 1;
  Q[1] = s;
  while (_h < _t) {
    int u = Q[++_h];
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].to, w = e[i].w;
      if (w > 0 && !dep[v]) {
        dep[v] = dep[u] + 1;
        Q[++_t] = v;
        if (v == t) return 1;
      }
    }
  }
  return 0;
}
int dfs(int u, int _w) {
  if (u == t || !_w) return _w;
  int s = 0;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to, w = e[i].w;
    if (w > 0 && dep[v] == dep[u] + 1) {
      int di = dfs(v, min(_w - s, w));
      e[i].w -= di;
      e[i ^ 1].w += di;
      s += di;
      if (s == _w) break;
    }
  }
  if (s < _w) dep[u] = 0;
  return s;
}
int mf, _mf;
void dinic() {
  while (bfs()) mf += dfs(s, 1000000000);
}
int ans[200010];
long long Ans;
int main() {
  memset(head, -1, sizeof head);
  cin >> n >> m >> _R >> _B;
  init_hash();
  s = 0;
  t = cnt + Cnt + 1;
  ss = t + 1;
  tt = ss + 1;
  memset(A, 10, sizeof A);
  memset(B, 10, sizeof B);
  for (int i = 1; i <= m; ++i) {
    int opt, x, y, p;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) {
      p = lower_bound(b + 1, b + cnt + 1, x) - b;
      if (p > cnt || b[p] != x) continue;
      A[p] = min(A[p], y);
    } else {
      p = lower_bound(c + 1, c + Cnt + 1, x) - c;
      if (p > Cnt || c[p] != x) continue;
      B[p] = min(B[p], y);
    }
  }
  for (int i = 1; i <= n; ++i) ++s1[a[i].l], ++s2[a[i].r];
  for (int i = 1; i <= cnt; ++i) {
    int l = (s1[i] - A[i] + 1) / 2, r = (s1[i] + A[i]) / 2;
    if (l > r) return puts("-1"), 0;
    Add_edge(s, i, max(0, l), min(s1[i], r));
  }
  for (int i = 1; i <= Cnt; ++i) {
    int l = (s2[i] - B[i] + 1) / 2, r = (s2[i] + B[i]) / 2;
    if (l > r) return puts("-1"), 0;
    Add_edge(i + cnt, t, max(0, l), min(s2[i], r));
  }
  for (int i = 1; i <= n; ++i)
    Add_edge(a[i].l, a[i].r + cnt, 0, 1), id[i] = c1 - 2;
  Add_edge(t, s, 0, 1000000000);
  for (int i = s; i <= t; ++i)
    if (in[i] > out[i])
      Add_edge(ss, i, 0, in[i] - out[i]), _mf += in[i] - out[i];
    else
      Add_edge(i, tt, 0, out[i] - in[i]);
  swap(ss, s);
  swap(tt, t);
  dinic();
  swap(ss, s);
  swap(tt, t);
  if (_mf != mf) return puts("-1"), 0;
  for (int i = head[ss]; ~i; i = e[i].next) e[i].w = e[i ^ 1].w = 0;
  for (int i = head[tt]; ~i; i = e[i].next) e[i].w = e[i ^ 1].w = 0;
  for (int i = head[t]; ~i; i = e[i].next)
    if (e[i].to == s) e[i].w = e[i ^ 1].w = 0;
  dinic();
  for (int i = 1; i <= n; ++i) ans[i] = !e[id[i]].w;
  for (int i = 1; i <= n; ++i) Ans += ans[i] ? min(_R, _B) : max(_R, _B);
  cout << Ans << endl;
  for (int i = 1; i <= n; ++i) {
    if (ans[i])
      putchar(_R <= _B ? 'r' : 'b');
    else
      putchar(_R <= _B ? 'b' : 'r');
  }
  return 0;
}