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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return b < a ? a : b;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
inline void failure() {
  puts("-1");
  exit(0);
}
const int _ = 100007, inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
struct netflow {
  static const int _n = _ * 2, _e = _ * 33;
  int to[_e], ne[_e], he[_n], ecnt;
  long long ev[_e], ped[_n];
  void adde(int a, int b, long long c) {
    to[++ecnt] = b, ev[ecnt] = c, ne[ecnt] = he[a], he[a] = ecnt;
  }
  void addde(int a, int b, long long c) { adde(a, b, c), adde(b, a, 0); }
  void addpe(int a, int b, long long l, long long r) {
    addde(a, b, r - l), ped[a] -= l, ped[b] += l;
  }
  int S, T, dcnt, dis[_n], gap[_n];
  long long dfs(int x, long long f) {
    if (x == T || !f) return f;
    long long r = f;
    int mid = dcnt - 1;
    for (int i = he[x]; i; i = ne[i]) {
      if (ev[i] <= 0) continue;
      int b = to[i];
      if (dis[b] + 1 == dis[x]) {
        long long g = dfs(b, min(r, ev[i]));
        ev[i] -= g, ev[i ^ 1] += g, r -= g;
        if (dis[S] >= dcnt) return f - r;
        if (!r) break;
      }
      mid = min(mid, dis[b]);
    }
    if (f == r) {
      if (--gap[dis[x]] == 0) dis[S] = dcnt;
      dis[x] = mid + 1, gap[dis[x]]++;
    }
    return f - r;
  }
  inline long long run(int s, int t) {
    S = s, T = t;
    memset(dis, 0, sizeof(dis)), memset(gap, 0, sizeof(gap));
    long long sflw = 0;
    while (dis[s] < dcnt) sflw += dfs(s, linf);
    return sflw;
  }
  inline long long finder(int s, int t, int ss, int tt) {
    long long tar = 0;
    for (int i = 1; i <= dcnt; i++) {
      if (ped[i] > 0)
        addde(ss, i, ped[i]), tar += ped[i];
      else
        addde(i, tt, -ped[i]);
    }
    addde(t, s, linf);
    if (run(ss, tt) != tar) return -1;
    return run(s, t);
  }
  netflow() {
    memset(ped, 0, sizeof(ped)), memset(he, 0, sizeof(he)), ecnt = 1;
  }
} nf;
struct hasher {
  unordered_map<int, int> ha;
  int hacnt;
  inline int isthere(int x) { return ha.count(x); }
  inline int hashie(int x) {
    if (!ha.count(x)) ha[x] = ++hacnt;
    return ha[x];
  }
  hasher() { ha.clear(), hacnt = 0; }
} ha[2];
int n, loc[_][2], m, xlim[_], vlim[_], typ[_], col, cor, corev = 0;
int xcnt, ycnt, cnt[2][_] = {0}, lim[2][_], bel[_];
int main() {
  n = ty(), m = ty();
  col = ty(), cor = ty();
  if (col > cor) swap(col, cor), corev = 1;
  for (int i = 1; i <= n; i++)
    loc[i][0] = ha[0].hashie(ty()), loc[i][1] = ha[1].hashie(ty());
  for (int i = 1; i <= m; i++) {
    typ[i] = ty() - 1, xlim[i] = ty(), vlim[i] = ty();
    if (!ha[typ[i]].isthere(xlim[i])) {
      i--, m--;
      continue;
    }
    xlim[i] = ha[typ[i]].hashie(xlim[i]);
  }
  xcnt = ha[0].hacnt, ycnt = ha[1].hacnt;
  for (int i = 1; i <= n; i++) {
    cnt[0][loc[i][0]]++, cnt[1][loc[i][1]]++;
    nf.addde(loc[i][0], xcnt + loc[i][1], 1), bel[i] = nf.ecnt - 1;
  }
  for (int i = 1; i <= max(xcnt, ycnt); i++)
    lim[0][i] = cnt[0][i], lim[1][i] = cnt[1][i];
  for (int i = 1; i <= m; i++)
    lim[typ[i]][xlim[i]] = min(lim[typ[i]][xlim[i]], vlim[i]);
  nf.dcnt = xcnt + ycnt;
  int s = ++nf.dcnt, t = ++nf.dcnt, ss = ++nf.dcnt, tt = ++nf.dcnt;
  for (int i = 1; i <= xcnt; i++) {
    int l = (cnt[0][i] - lim[0][i] + 1) / 2, r = (cnt[0][i] + lim[0][i]) / 2;
    if (l > r) failure();
    nf.addpe(s, i, l, r);
  }
  for (int i = 1; i <= ycnt; i++) {
    int l = (cnt[1][i] - lim[1][i] + 1) / 2, r = (cnt[1][i] + lim[1][i]) / 2;
    if (l > r) failure();
    nf.addpe(xcnt + i, t, l, r);
  }
  long long ans = nf.finder(s, t, ss, tt);
  if (ans < 0) failure();
  printf("%I64d\n", 1ll * ans * col + 1ll * (n - ans) * cor);
  for (int i = 1; i <= n; i++) putchar("rb"[corev ^ (nf.ev[bel[i]] > 0)]);
  puts("");
  return 0;
}