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;
int read();
void chmin(int &x, int y) { x > y ? x = y : x; }
int n, m, r, b;
int stx[200005], tpx, sty[200005], tpy;
struct P {
  int x, y;
} p[200005];
int sum[400005], lim[400005];
int s, t, S, T;
int in[400005];
int hd[400005], nx[2000006], to[2000006], c[2000006], cnt, tcnt;
void add(int f, int t, int cap) {
  nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t, c[cnt] = cap;
}
void sadd(int f, int t, int c) { add(f, t, c), add(t, f, 0); }
void fadd(int f, int t, int d, int u) {
  if (d > u) puts("-1"), exit(0);
  sadd(f, t, u - d), in[t] += d, in[f] -= d;
}
int dep[400005];
queue<int> q;
bool bfs(int S, int T) {
  for (int i = 1; i <= T; ++i) dep[i] = 0;
  dep[S] = 1, q.push(S);
  for (int u; !q.empty(); q.pop())
    for (int i = hd[u = q.front()], v; i; i = nx[i])
      if (!dep[v = to[i]] && c[i] > 0) q.push(v), dep[v] = dep[u] + 1;
  return dep[T];
}
int iter[400005];
int dfs(int u, int T, int dist) {
  if (u == T) return dist;
  for (int &i = iter[u], v, d; i; i = nx[i]) {
    if (dep[v = to[i]] != dep[u] + 1 || c[i] < 1) continue;
    if (d = dfs(v, T, min(dist, c[i]))) return c[i] -= d, c[i ^ 1] += d, d;
  }
  return 0;
}
void Dinic(int S, int T) {
  while (bfs(S, T)) {
    for (int i = 1; i <= T; ++i) iter[i] = hd[i];
    while (dfs(S, T, 100000000)) void();
  }
}
map<int, int> mp[200005];
int main() {
  n = read(), m = read(), r = read(), b = read(), cnt = 1;
  for (int i = 1; i <= n; ++i)
    p[i].x = stx[i] = read(), p[i].y = sty[i] = read();
  sort(stx + 1, stx + 1 + n), tpx = unique(stx + 1, stx + 1 + n) - stx - 1;
  sort(sty + 1, sty + 1 + n), tpy = unique(sty + 1, sty + 1 + n) - sty - 1;
  t = (s = tpx + tpy + 1) + 1, T = (S = t + 1) + 1;
  for (int i = 1; i <= n; ++i) {
    p[i].x = lower_bound(stx + 1, stx + 1 + tpx, p[i].x) - stx;
    p[i].y = lower_bound(sty + 1, sty + 1 + tpy, p[i].y) - sty + tpx;
    sum[p[i].x]++, sum[p[i].y]++;
  }
  for (int i = 1; i <= tpx + tpy; ++i) lim[i] = sum[i];
  for (int i = 1, o, l, tl, d; i <= m; ++i) {
    o = read(), l = read(), d = read();
    if (o & 1)
      tl = lower_bound(stx + 1, stx + 1 + tpx, l) - stx;
    else
      tl = lower_bound(sty + 1, sty + 1 + tpy, l) - sty;
    if ((o & 1 ? stx : sty)[tl] == l) chmin(lim[tl + (o & 1 ? 0 : tpx)], d);
  }
  for (int i = 1; i <= tpx + tpy; ++i) {
    (i <= tpx) ? fadd(s, i, sum[i] - lim[i] + 1 >> 1, sum[i] + lim[i] >> 1)
               : fadd(i, t, sum[i] - lim[i] + 1 >> 1, sum[i] + lim[i] >> 1);
  }
  fadd(t, s, 0, 1000000000);
  for (int i = 1; i <= n; ++i) fadd(p[i].x, p[i].y, 0, 1);
  tcnt = cnt;
  for (int i = 1; i <= t; ++i) {
    if (in[i] > 0) sadd(S, i, in[i]);
    if (in[i] < 0) sadd(i, T, -in[i]);
  }
  Dinic(S, T);
  for (int i = tcnt + 1; i <= cnt; i += 2)
    if (c[i]) return puts("-1"), 0;
  for (int i = 1; i <= t; ++i)
    while (hd[i] > tcnt) hd[i] = nx[hd[i]];
  Dinic(s, t);
  int res = 0;
  for (int u = 1; u <= tpx; ++u)
    for (int i = hd[u]; i; i = nx[i])
      if (to[i] <= tpx + tpy && !c[i]) ++res, ++mp[u][to[i]];
  int flg = 0;
  if (r > b) flg = 1, swap(r, b);
  printf("%lld\n", 1ll * res * r + 1ll * (n - res) * b);
  for (int i = 1; i <= n; ++i)
    (mp[p[i].x][p[i].y]) ? (putchar(flg ? 'b' : 'r'), --mp[p[i].x][p[i].y])
                         : putchar(flg ? 'r' : 'b');
  return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
int read() {
  int x = 0, f = 1;
  char c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
            (iS == iT ? EOF : *iS++) : *iS++);
  while (!isdigit(c))
    f = (c == '-') ? -1 : f,
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  while (isdigit(c))
    x = x * 10 + c - '0',
    c = (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)),
         (iS == iT ? EOF : *iS++) : *iS++);
  return x * f;
}