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 = 200015, Inf = 1e9;
inline int gi() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
  return sum;
}
int n, nx, ny, m, r, b, px[maxn], x[maxn], py[maxn], y[maxn], minx[maxn],
    miny[maxn], cntx[maxn], cnty[maxn];
struct edge {
  int to, next, cap;
} e[maxn << 5];
int s, t, S, T, h[maxn], _h[maxn], d[maxn], cur[maxn], Id[maxn], tot = 1, pos;
inline void add(int u, int v, int c) {
  e[++tot] = (edge){v, h[u], c};
  h[u] = tot;
  e[++tot] = (edge){u, h[v], 0};
  h[v] = tot;
}
inline void adde(int u, int v, int b, int c) {
  if (b > c) puts("-1"), exit(0);
  b = max(0, b);
  d[u] -= b;
  d[v] += b;
  add(u, v, c - b);
}
bool bfs(int S, int T) {
  static int l, r, q[maxn], vis[maxn], Time;
  l = 0;
  r = 1;
  q[r] = S;
  ++Time;
  d[S] = 0;
  vis[S] = Time;
  while (l < r) {
    int u = q[++l];
    for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
      if (vis[v] != Time && e[i].cap) {
        d[v] = d[u] + 1;
        vis[v] = Time;
        q[++r] = v;
      }
  }
  return vis[T] == Time;
}
int dfs(int u, int t, int a) {
  if (u == t || !a) return a;
  int f, flow = 0;
  for (int &i = cur[u], v; v = e[i].to, i; i = e[i].next)
    if (d[v] == d[u] + 1 && (f = dfs(v, t, min(a, e[i].cap)))) {
      e[i].cap -= f;
      e[i ^ 1].cap += f;
      flow += f;
      a -= f;
      if (!a) break;
    }
  return flow;
}
int maxflow(int s, int t) {
  int flow = 0;
  while (bfs(s, t)) {
    memcpy(cur, h, sizeof(int) * (t + 1));
    flow += dfs(s, t, Inf);
  }
  return flow;
}
int main() {
  n = nx = ny = gi();
  m = gi();
  int flg = 0;
  r = gi();
  b = gi();
  if (r < b) swap(r, b), flg = 1;
  for (int i = 1; i <= n; ++i) px[i] = x[i] = gi(), py[i] = y[i] = gi();
  sort(px + 1, px + nx + 1);
  nx = unique(px + 1, px + nx + 1) - px - 1;
  sort(py + 1, py + ny + 1);
  ny = unique(py + 1, py + ny + 1) - py - 1;
  for (int i = 1; i <= n; ++i) {
    x[i] = lower_bound(px + 1, px + nx + 1, x[i]) - px;
    ++cntx[x[i]];
    y[i] = lower_bound(py + 1, py + ny + 1, y[i]) - py;
    ++cnty[y[i]];
  }
  fill(minx + 1, minx + nx + 1, n + 1);
  fill(miny + 1, miny + ny + 1, n + 1);
  for (int t, l, d, p, i = 1; i <= m; ++i) {
    t = gi();
    l = gi();
    d = gi();
    if (t == 1) {
      p = lower_bound(px + 1, px + nx + 1, l) - px;
      if (px[p] != l) continue;
      minx[p] = min(minx[p], d);
    } else {
      p = lower_bound(py + 1, py + ny + 1, l) - py;
      if (py[p] != l) continue;
      miny[p] = min(miny[p], d);
    }
  }
  s = nx + ny + 1;
  t = s + 1;
  S = t + 1;
  T = S + 1;
  for (int i = 1; i <= nx; ++i)
    adde(s, i, (cntx[i] - minx[i] + 1) / 2, (cntx[i] + minx[i]) / 2);
  for (int i = 1; i <= ny; ++i)
    adde(nx + i, t, (cnty[i] - miny[i] + 1) / 2, (cnty[i] + miny[i]) / 2);
  for (int i = 1; i <= n; ++i) adde(x[i], nx + y[i], 0, 1), Id[i] = tot ^ 1;
  memcpy(_h + 1, h + 1, sizeof(int) * t);
  adde(t, s, 0, Inf);
  pos = tot;
  for (int i = 1; i <= t; ++i) {
    if (d[i] < 0) add(i, T, -d[i]);
    if (d[i] > 0) add(S, i, d[i]);
  }
  int res = 0;
  maxflow(S, T);
  res = e[pos].cap;
  for (int i = h[S]; i; i = e[i].next)
    if (e[i].cap) return puts("-1"), 0;
  memcpy(h + 1, _h + 1, sizeof(int) * T);
  res += maxflow(s, t);
  printf("%lld\n", (long long)n * r - (long long)res * (r - b));
  for (int i = 1; i <= n; ++i) putchar((flg ^ e[Id[i]].cap) ? 'r' : 'b');
  return 0;
}