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 = 200010;
struct edge {
  long long to, next, w;
} e[N * 10];
long long head[N], ecnt = 1, extra[N];
inline void adde(long long from, long long to, long long w) {
  e[++ecnt] = (edge){to, head[from], w}, head[from] = ecnt;
  e[++ecnt] = (edge){from, head[to], 0}, head[to] = ecnt;
}
inline void adde(long long from, long long to, long long down, long long up) {
  long long delta = up - down;
  adde(from, to, delta);
  extra[to] += down, extra[from] -= down;
}
long long dep[N], cur[N];
inline bool BFS(long long s, long long t) {
  memset(dep, 0, sizeof(dep)), dep[s] = 1;
  queue<long long> q;
  q.push(s);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (long long i = head[u]; i; i = e[i].next)
      if (e[i].w && !dep[e[i].to]) {
        assert(e[i].w > 0);
        dep[e[i].to] = dep[u] + 1, q.push(e[i].to);
        if (e[i].to == t) return true;
      }
  }
  return false;
}
long long DFS(long long u, long long f, long long t) {
  if (u == t || !f) return f;
  long long res = 0;
  for (long long &i = cur[u], tmp; i; i = e[i].next)
    if (e[i].w && dep[e[i].to] == dep[u] + 1 &&
        (tmp = DFS(e[i].to, min(f, e[i].w), t))) {
      e[i].w -= tmp, e[i ^ 1].w += tmp, f -= tmp, res += tmp;
      if (!f) break;
    }
  return res;
}
inline long long dinic(long long s, long long t) {
  long long res = 0;
  while (BFS(s, t)) memcpy(cur, head, sizeof(head)), res += DFS(s, 1e18, t);
  return res;
}
inline long long FUCKYPJ(long long S, long long T, long long n) {
  long long s = T + 1, t = s + 1, tot = 0;
  for (long long i = 1; i <= n; i++)
    if (extra[i] > 0)
      adde(s, i, extra[i]), tot += extra[i];
    else
      adde(i, t, -extra[i]);
  adde(T, S, 0, 1e9);
  if (dinic(s, t) != tot) return -1;
  long long res = 0;
  for (long long i = head[S]; i; i = e[i].next)
    if (e[i].to == T) res = e[i].w, e[i].w = 0;
  return res + dinic(S, T);
}
long long x[N], y[N], id[N];
map<long long, long long> X, Y, X1, Y1, X2, Y2;
signed main() {
  long long n, m, r, b, flag = 0;
  scanf("%lld%lld%lld%lld", &n, &m, &r, &b);
  if (r > b) swap(r, b), flag = 1;
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld", &x[i], &y[i]), X[x[i]]++, Y[y[i]]++;
  long long A = X.size(), B = Y.size(), s = A + B + 1, t = s + 1;
  for (long long i = 1; i <= m; i++) {
    long long t, l, d;
    scanf("%lld%lld%lld", &t, &l, &d);
    if (t == 1) {
      if (!X1.count(l))
        X1[l] = d;
      else
        X1[l] = min(X1[l], d);
    } else {
      if (!Y1.count(l))
        Y1[l] = d;
      else
        Y1[l] = min(Y1[l], d);
    }
  }
  long long ct = 0;
  for (auto t : X) {
    long long t1 = t.first, all = t.second;
    X2[t1] = ++ct;
    long long lim = X1.count(t1) ? X1[t1] : 1e9;
    long long L = (all - lim + 1) / 2, R = min(n, (all + lim) / 2);
    if (L > R) return puts("-1"), 0;
    adde(s, ct, L, R);
  }
  for (auto T : Y) {
    long long t1 = T.first, all = T.second;
    Y2[t1] = ++ct;
    long long lim = Y1.count(t1) ? Y1[t1] : 1e9;
    long long L = max(0ll, (all - lim + 1) / 2), R = min(n, (all + lim) / 2);
    if (L > R) return puts("-1"), 0;
    adde(ct, t, L, R);
  }
  for (long long i = 1; i <= n; i++)
    adde(X2[x[i]], Y2[y[i]], 0, 1), id[i] = ecnt - 1;
  long long res = FUCKYPJ(s, t, t);
  if (res == -1)
    puts("-1");
  else {
    printf("%lld\n", (long long)res * r + (long long)(n - res) * b);
    for (long long i = 1; i <= n; i++) {
      long long t = e[id[i]].w ^ flag;
      if (!t)
        putchar('r');
      else
        putchar('b');
    }
  }
}