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>
const int maxn = 1e5 + 7;
const int maxe = 3e6 + 7;
const long long inf = 1e17;
using namespace std;
long long n, m, R, B, s, t, op, l, d, ns, nt, cnt;
long long x[maxn], y[maxn], sx[maxn], sy[maxn], mn[maxn * 2], mx[maxn * 2],
    num[maxn], deg[maxn * 2];
long long ls[maxn * 2], dis[maxn * 2];
queue<long long> q;
struct edge {
  long long y, w, op, next;
} g[maxe];
struct rec {
  long long x, y;
} a[maxn];
void add(long long x, long long y, long long w) {
  g[++cnt] = (edge){y, w, cnt + 1, ls[x]};
  ls[x] = cnt;
  g[++cnt] = (edge){x, 0, cnt - 1, ls[y]};
  ls[y] = cnt;
}
bool bfs() {
  while (!q.empty()) q.pop();
  for (long long i = 0; i <= nt; i++) dis[i] = inf;
  dis[ns] = 0;
  q.push(ns);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (long long i = ls[x]; i > 0; i = g[i].next) {
      long long y = g[i].y;
      if ((g[i].w) && (dis[y] > dis[x] + 1)) {
        dis[y] = dis[x] + 1;
        if (y == nt) return 1;
        q.push(y);
      }
    }
  }
  return 0;
}
long long dfs(long long x, long long maxf) {
  if ((x == nt) || (maxf == 0)) return maxf;
  long long ret = 0;
  for (long long i = ls[x]; i > 0; i = g[i].next) {
    long long y = g[i].y;
    if ((dis[y] == dis[x] + 1) && (g[i].w)) {
      long long f = dfs(y, min(maxf - ret, g[i].w));
      if (!f) dis[y] = 0;
      ret += f;
      g[i].w -= f;
      g[g[i].op].w += f;
      if (ret == maxf) break;
    }
  }
  return ret;
}
long long dinic() {
  long long flow = 0;
  while (bfs()) flow += dfs(ns, inf);
  return flow;
}
int main() {
  scanf("%I64d%I64d", &n, &m);
  scanf("%I64d%I64d", &R, &B);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &a[i].x, &a[i].y);
    x[i] = a[i].x;
    y[i] = a[i].y;
  }
  sort(x + 1, x + n + 1);
  sort(y + 1, y + n + 1);
  long long size1 = unique(x + 1, x + n + 1) - x - 1,
            size2 = unique(y + 1, y + n + 1) - y - 1;
  s = 0, t = size1 + size2 + 1;
  for (long long i = 1; i <= n; i++) {
    long long xx = lower_bound(x + 1, x + size1 + 1, a[i].x) - x;
    long long yy = lower_bound(y + 1, y + size2 + 1, a[i].y) - y;
    add(xx, yy + size1, 1);
    sx[xx]++, sy[yy]++, num[i] = cnt - 1;
  }
  for (long long i = 1; i <= size1 + size2; i++) mn[i] = 0, mx[i] = n;
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &op, &l, &d);
    if (op == 1) {
      long long p = lower_bound(x + 1, x + size1 + 1, l) - x;
      if ((x[p] != l) || (d >= sx[p])) continue;
      long long L = (sx[p] - d + 1) / 2, R = sx[p] - L;
      if (L > R) {
        printf("-1");
        return 0;
      }
      mx[p] = min(mx[p], R);
      mn[p] = max(mn[p], L);
    } else {
      long long p = lower_bound(y + 1, y + size2 + 1, l) - y;
      if ((y[p] != l) || (d >= sy[p])) continue;
      long long L = (sy[p] - d + 1) / 2, R = sy[p] - L;
      if (L > R) {
        printf("-1");
        return 0;
      }
      mx[p + size1] = min(mx[p + size1], R);
      mn[p + size1] = max(mn[p + size1], L);
    }
  }
  for (long long i = 1; i <= size1; i++) {
    deg[s] -= mn[i];
    deg[i] += mn[i];
    add(s, i, min(sx[i], mx[i]) - mn[i]);
  }
  for (long long i = size1 + 1; i <= size1 + size2; i++) {
    deg[i] -= mn[i];
    deg[t] += mn[i];
    add(i, t, min(sy[i - size1], mx[i]) - mn[i]);
  }
  long long nowcnt = cnt, S = t + 1, T = t + 2;
  add(t, s, inf);
  long long sum = 0;
  for (long long i = s; i <= t; i++) {
    if (deg[i] < 0)
      add(i, T, -deg[i]);
    else if (deg[i] > 0)
      add(S, i, deg[i]), sum += deg[i];
  }
  ns = S, nt = T;
  int x1;
  if ((x1 = dinic()) != sum) {
    printf("-1");
    return 0;
  }
  for (long long i = nowcnt + 1; i <= cnt; i++) g[i].w = 0;
  ns = s, nt = t;
  int x = dinic();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!g[num[i]].w)
      ans += min(B, R);
    else
      ans += max(B, R);
  }
  printf("%I64d\n", ans);
  for (long long i = 1; i <= n; i++) {
    if (!g[num[i]].w) {
      if (B < R)
        printf("b");
      else
        printf("r");
    } else {
      if (B < R)
        printf("r");
      else
        printf("b");
    }
  }
}