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 = 1e6 + 10;
const long long Inf = 1e18;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int to[N << 1], nxt[N << 1], h[N], tt = 1, dep[N], s, t, nc = 0, n, m, r, b,
                                   cur[N];
long long f[N], ww[N << 1];
void adde(int u, int v, long long w) {
  to[++tt] = v, ww[tt] = w, nxt[tt] = h[u], h[u] = tt;
  to[++tt] = u, ww[tt] = 0, nxt[tt] = h[v], h[v] = tt;
}
void adde(int u, int v, int l, int r) {
  if (l > r) {
    puts("-1");
    exit(0);
  }
  adde(u, v, r - l), f[u] -= l, f[v] += l;
}
bool bfs(int s, int t) {
  for (int i = 0; i <= nc; i++) dep[i] = 0;
  queue<int> Q;
  Q.push(s);
  dep[s] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = h[u], v; v = to[i], i; i = nxt[i])
      if (!dep[v] && ww[i]) dep[v] = dep[u] + 1, Q.push(v);
  }
  return dep[t];
}
long long dfs(int u, int t, long long flow) {
  if (u == t) return flow;
  int ret = 0;
  for (int &i = cur[u], v; v = to[i], i; i = nxt[i])
    if (dep[v] == dep[u] + 1 && ww[i]) {
      long long d = dfs(v, t, min(flow, ww[i]));
      ww[i] -= d, ww[i ^ 1] += d, ret += d, flow -= d;
      if (!flow) break;
    }
  return ret;
}
long long dinic(int s, int t) {
  long long ret = 0;
  while (bfs(s, t)) {
    for (int i = 0; i <= nc; i++) cur[i] = h[i];
    ret += dfs(s, t, Inf);
  }
  return ret;
}
map<int, int> idx, idy;
int ttx = 0, tty = 0, x[N], y[N], mnx[N], mny[N], cntx[N], cnty[N];
map<pair<int, int>, int> blu;
bool fl = 0;
int main() {
  cin >> n >> m >> r >> b;
  if (r > b) swap(r, b), fl = 1;
  for (int i = 1; i <= n; i++) {
    x[i] = gi(), y[i] = gi();
    if (!idx.count(x[i])) idx[x[i]] = ++ttx;
    x[i] = idx[x[i]];
    if (!idy.count(y[i])) idy[y[i]] = ++tty;
    y[i] = idy[y[i]];
    ++cntx[x[i]], ++cnty[y[i]];
  }
  memset(mnx, 0x3f, sizeof(mnx));
  memset(mny, 0x3f, sizeof(mny));
  for (int i = 1; i <= m; i++) {
    int t = gi(), l = gi(), d = gi();
    if (t & 1) {
      if (!idx.count(l)) continue;
      l = idx[l], mnx[l] = min(mnx[l], d);
    } else {
      if (!idy.count(l)) continue;
      l = idy[l], mny[l] = min(mny[l], d);
    }
  }
  long long ans = 1ll * n * r;
  nc = ttx + tty, s = ++nc, t = ++nc;
  for (int i = 1; i <= ttx; i++)
    if (mnx[i] < n)
      adde(s, i, max(0, (cntx[i] - mnx[i] + 1) / 2), (cntx[i] + mnx[i]) / 2);
    else
      adde(s, i, 0, n);
  for (int i = 1; i <= tty; i++)
    if (mny[i] < n)
      adde(i + ttx, t, max(0, (cnty[i] - mny[i] + 1) / 2),
           (cnty[i] + mny[i]) / 2);
    else
      adde(i + ttx, t, 0, n);
  for (int i = 1; i <= n; i++) adde(x[i], y[i] + ttx, 0, 1);
  int ss = ++nc, tt = ++nc;
  for (int i = 1; i <= nc; i++) {
    if (f[i] > 0)
      adde(ss, i, f[i]);
    else if (f[i] < 0)
      adde(i, tt, -f[i]);
  }
  adde(t, s, Inf);
  dinic(ss, tt);
  ans += 1ll * ww[::tt] * (b - r);
  for (int i = h[ss]; i; i = nxt[i])
    if (ww[i]) return puts("-1"), 0;
  h[s] = nxt[h[s]], h[t] = nxt[h[t]], ans -= 1ll * dinic(t, s) * (b - r);
  cout << ans << '\n';
  for (int u = 1; u <= ttx; u++)
    for (int i = h[u], v; v = to[i], i; i = nxt[i])
      if (1 <= v - ttx && v - ttx <= tty)
        blu[make_pair(u, v - ttx)] += ww[i ^ 1];
  for (int i = 1; i <= n; i++) {
    if (blu[make_pair(x[i], y[i])])
      --blu[make_pair(x[i], y[i])], putchar(fl ? 'r' : 'b');
    else
      putchar(fl ? 'b' : 'r');
  }
  return 0;
}