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 N = 100010;
const int M = 2100000;
const int INF = 0x3f3f3f3f;
int n, m, r, b;
int S, T, SS, TT, num, tot = 1, ans, sum1;
int a[2][N], cnt[2], X[N], Y[N], sum[2][N];
int head[N << 1], nex[M], to[M], val[M];
int mx[2][N], mn[2][N], du[N << 1];
int d[N << 1], pos[N];
queue<int> Q;
int get(int x, int y) {
  return lower_bound(a[y] + 1, a[y] + 1 + cnt[y], x) - a[y];
}
void add(int x, int y, int z) {
  tot++;
  nex[tot] = head[x];
  head[x] = tot;
  to[tot] = y;
  val[tot] = z;
}
int bfs(int S, int T) {
  memset(d, -1, sizeof(d));
  while (!Q.empty()) Q.pop();
  d[S] = 0;
  Q.push(S);
  while (!Q.empty()) {
    int tmp = Q.front();
    Q.pop();
    for (int i = head[tmp]; i; i = nex[i])
      if (d[to[i]] == -1 && val[i]) {
        d[to[i]] = d[tmp] + 1;
        if (to[i] == T) return 1;
        Q.push(to[i]);
      }
  }
  return 0;
}
int dfs(int x, int mv, int T) {
  if (x == T) return mv;
  int tmp = 0;
  for (int i = head[x]; i; i = nex[i])
    if (d[to[i]] == d[x] + 1 && val[i]) {
      int t = dfs(to[i], min(val[i], mv - tmp), T);
      if (!t) d[to[i]] = -1;
      tmp += t;
      val[i] -= t;
      val[i ^ 1] += t;
      if (tmp == mv) break;
    }
  return tmp;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &X[i], &Y[i]);
    a[0][++cnt[0]] = X[i];
    a[1][++cnt[1]] = Y[i];
  }
  for (int i = 0; i <= 1; i++) {
    sort(a[i] + 1, a[i] + 1 + cnt[i]);
    cnt[i] = unique(a[i] + 1, a[i] + 1 + cnt[i]) - a[i] - 1;
  }
  num = cnt[0] + cnt[1];
  S = ++num;
  T = ++num;
  SS = ++num;
  TT = ++num;
  for (int i = 1; i <= n; i++) {
    X[i] = get(X[i], 0);
    Y[i] = get(Y[i], 1);
    sum[0][X[i]]++;
    sum[1][Y[i]]++;
    add(X[i], Y[i] + cnt[0], 1);
    pos[i] = tot;
    add(Y[i] + cnt[0], X[i], 0);
  }
  for (int i = 0; i <= 1; i++)
    for (int j = 1; j <= cnt[i]; j++) mx[i][j] = sum[i][j];
  int t, l, d;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &t, &l, &d);
    t--;
    int t1 = get(l, t);
    if (a[t][t1] != l) continue;
    mx[t][t1] = min(mx[t][t1], (d + sum[t][t1]) / 2);
    mn[t][t1] = max(mn[t][t1], (sum[t][t1] - d + 1) / 2);
    if (mx[t][t1] < mn[t][t1]) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= cnt[0]; i++) {
    if (mx[0][i] != mn[0][i]) {
      add(S, i, mx[0][i] - mn[0][i]);
      add(i, S, 0);
    }
    du[i] += mn[0][i];
    du[S] -= mn[0][i];
  }
  for (int i = 1; i <= cnt[1]; i++) {
    int t = i + cnt[0];
    if (mx[1][i] != mn[1][i]) {
      add(t, T, mx[1][i] - mn[1][i]);
      add(T, t, 0);
    }
    du[T] += mn[1][i];
    du[t] -= mn[1][i];
  }
  for (int i = 1; i <= T; i++)
    if (du[i]) {
      if (du[i] > 0)
        add(SS, i, du[i]), add(i, SS, 0), sum1 += du[i];
      else
        add(i, TT, -du[i]), add(TT, i, 0);
    }
  add(T, S, INF);
  add(S, T, 0);
  while (bfs(SS, TT)) ans += dfs(SS, INF, TT);
  if (ans != sum1) {
    printf("-1\n");
    return 0;
  }
  ans = 0;
  while (bfs(S, T)) ans += dfs(S, INF, T);
  printf("%I64d\n",
         (long long)ans * min(r, b) + (long long)(n - ans) * max(r, b));
  for (int i = 1; i <= n; i++) {
    if (!val[pos[i]])
      putchar(r < b ? 'r' : 'b');
    else
      putchar(r > b ? 'r' : 'b');
  }
  return 0;
}