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;
queue<int> q;
int d[600010];
const int inf = 1e9;
int sums[2];
int flag;
int tot, s[3000010];
int cur[600010];
int n, m, r, b;
int x[300010], y[300010];
int sum[300010][2];
int t[300010], l[300010], p[300010];
int maxn;
int mx[300010][2], mn[300010][2];
int addnum, vel[3000010], ne[3000010], key[3000010], head[600010];
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  return ans;
}
void add(int u, int v, int k) {
  addnum++, vel[addnum] = v, key[addnum] = k, ne[addnum] = head[u],
            head[u] = addnum;
  addnum++, vel[addnum] = u, key[addnum] = 0, ne[addnum] = head[v],
            head[v] = addnum;
}
int dfs(int u, int k, int ed) {
  if (u == ed) return k;
  int used = 0;
  for (int &e = cur[u]; e; e = ne[e]) {
    int v = vel[e];
    if (d[v] == d[u] + 1 && key[e]) {
      int t = dfs(v, min(k - used, key[e]), ed);
      key[e] -= t, key[e ^ 1] += t;
      used += t;
      if (used == k) return k;
    }
  }
  return used;
}
int bfs(int S, int T) {
  for (int i = 0; i <= maxn; i++) d[i] = -1;
  d[S] = 0;
  q.push(S);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int e = head[u]; e; e = ne[e]) {
      int v = vel[e];
      if (!key[e]) continue;
      if (d[v] == -1) {
        d[v] = d[u] + 1;
        q.push(v);
      }
    }
  }
  return d[T] != -1;
}
int dinic(int S, int T) {
  int ans = 0;
  while (bfs(S, T)) {
    for (int i = 0; i <= maxn; i++) cur[i] = head[i];
    ans += dfs(S, inf, T);
  }
  return ans;
}
int main() {
  addnum = 1;
  n = read(), m = read();
  r = read(), b = read();
  if (r > b) swap(r, b), flag = 1;
  for (int i = 1; i <= n; i++)
    x[i] = read(), y[i] = read(), s[++tot] = x[i], s[++tot] = y[i];
  for (int i = 1; i <= m; i++)
    t[i] = read(), l[i] = read(), p[i] = read(), s[++tot] = l[i];
  sort(s + 1, s + tot + 1);
  tot = unique(s + 1, s + tot + 1) - s - 1;
  for (int i = 1; i <= n; i++)
    x[i] = lower_bound(s + 1, s + tot + 1, x[i]) - s,
    y[i] = lower_bound(s + 1, s + tot + 1, y[i]) - s;
  for (int i = 1; i <= m; i++) l[i] = lower_bound(s + 1, s + tot + 1, l[i]) - s;
  for (int i = 1; i <= n; i++) sum[x[i]][0]++, sum[y[i]][1]++;
  for (int i = 1; i <= tot; i++)
    for (int j = 0; j < 2; j++) mx[i][j] = inf;
  for (int i = 1; i <= m; i++) {
    int cas = t[i] - 1, num = l[i];
    if ((sum[num][cas] & 1) && !p[i]) {
      printf("-1\n");
      return 0;
    }
    mn[num][cas] = max(mn[num][cas], (sum[num][cas] - p[i] + 1) / 2);
    mx[num][cas] = min(mx[num][cas], (sum[num][cas] + p[i]) / 2);
  }
  for (int i = 1; i <= n; i++) add(x[i], y[i] + tot, 1);
  int S = 0, T = tot + tot + 1;
  for (int i = 1; i <= tot; i++)
    add(S, i, mx[i][0] - mn[i][0]), add(i + tot, T, mx[i][1] - mn[i][1]);
  int spS = tot + tot + 2, spT = tot + tot + 3;
  maxn = spT;
  for (int i = 1; i <= tot; i++)
    add(spS, i, mn[i][0]), add(i + tot, spT, mn[i][1]), sums[0] += mn[i][0],
        sums[1] += mn[i][1];
  add(S, spT, sums[0]), add(spS, T, sums[1]);
  add(T, S, inf);
  if (dinic(spS, spT) != sums[0] + sums[1]) {
    printf("-1\n");
    return 0;
  }
  long long ans = dinic(S, T);
  ans = ans * r + (n - ans) * b;
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++)
    if (key[i * 2] ^ flag)
      putchar('b');
    else
      putchar('r');
  puts("");
}