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;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long read1() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int M = 1e6 + 10;
const int N = 5e5 + 10;
const int inf = 1e9;
int n, m, r, b;
int S, T, SS, TT, num, tot, ans, sum1;
int a[2][N], cnt[2], first[N], second[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 Dep[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) {
  nex[++tot] = head[x];
  head[x] = tot;
  to[tot] = y;
  val[tot] = z;
}
int bfs(int S, int T) {
  memset(Dep, -1, sizeof(Dep));
  while (!Q.empty()) Q.pop();
  Dep[S] = 0;
  Q.push(S);
  while (!Q.empty()) {
    int tmp = Q.front();
    Q.pop();
    for (int i = head[tmp]; i; i = nex[i])
      if (Dep[to[i]] == -1 && val[i]) {
        Dep[to[i]] = Dep[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 (Dep[to[i]] == Dep[x] + 1 && val[i]) {
      int t = dfs(to[i], min(val[i], mv - tmp), T);
      if (!t) Dep[to[i]] = -1;
      tmp += t;
      val[i] -= t;
      val[i ^ 1] += t;
      if (tmp == mv) break;
    }
  return tmp;
}
int dinic() {
  int ans = 0;
  while (bfs(S, T)) ans += dfs(S, inf, T);
  return ans;
}
int main() {
  n = read();
  m = read();
  r = read();
  b = read();
  tot = 1;
  for (int i = 1; i <= n; i++) {
    first[i] = read();
    second[i] = read();
    a[0][++cnt[0]] = first[i];
    a[1][++cnt[1]] = second[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++) {
    first[i] = get(first[i], 0);
    sum[0][first[i]]++;
    second[i] = get(second[i], 1);
    sum[1][second[i]]++;
    add(first[i], second[i] + cnt[0], 1);
    pos[i] = tot;
    add(second[i] + cnt[0], first[i], 0);
  }
  for (int i = 0; i <= 1; i++)
    for (int j = 1; j <= cnt[i]; j++) mx[i][j] = sum[i][j];
  for (int i = 1; i <= m; i++) {
    int t = read();
    int l = read();
    int d = read();
    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]) {
      puts("-1");
      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) {
    puts("-1");
    return 0;
  }
  ans = dinic();
  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;
}