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 Maxx = 200010, INF = 0x3f3f3f3f;
inline int read() {
  int res = 0, bj = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9')
    res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
  return bj ? -res : res;
}
int n, m, R, B, X[Maxx], Y[Maxx], fx[Maxx], fy[Maxx];
int rx[Maxx], ry[Maxx], ux[Maxx], uy[Maxx], dx[Maxx], dy[Maxx];
int cnt = 1, E, cur[Maxx << 1], rh[Maxx << 1], h[Maxx << 1], to[Maxx * 10],
    nx[Maxx * 10], vl[Maxx * 10];
inline void ckmin(int &x, const int y) { x = x < y ? x : y; }
inline void ckmax(int &x, const int y) { x = x > y ? x : y; }
inline void Add(int x, int y, int v) {
  nx[++cnt] = h[x], to[h[x] = cnt] = y, vl[cnt] = v;
  nx[++cnt] = h[y], to[h[y] = cnt] = x, vl[cnt] = 0;
}
int d[Maxx], Q[Maxx];
inline bool Bfs(int x) {
  memset(d, -1, sizeof(int) * (E + 1));
  int l = 0, r = 0;
  d[Q[++r] = x] = 0;
  while (l < r) {
    for (int i = h[x = Q[++l]], y; i; i = nx[i])
      if (vl[i] && d[y = to[i]] == -1) {
        d[y] = d[x] + 1;
        if ((Q[++r] = y) == E) return 1;
      }
  }
  return 0;
}
int Dfs(int x, int Mx) {
  if (x == E) return Mx;
  int ret = 0, dlt;
  for (int i = h[x]; Mx && (h[x] = i); i = nx[i])
    if (vl[i] && d[to[i]] == d[x] + 1) {
      if ((dlt = Dfs(to[i], vl[i] < Mx ? vl[i] : Mx)))
        vl[i] -= dlt, vl[i ^ 1] += dlt, Mx -= dlt, ret += dlt;
      else
        d[to[i]] = 0;
    }
  return ret;
}
int P[Maxx];
signed main() {
  n = read(), m = read();
  int R = read(), B = read(), mx, my;
  char bj = 0;
  for (int i = 1; i <= n; ++i) X[i] = read(), Y[i] = read();
  if (R > B) bj = 1, swap(R, B), swap(X, Y);
  for (int i = 1; i <= n; ++i) fx[i] = X[i], fy[i] = Y[i];
  sort(fx + 1, fx + n + 1), mx = unique(fx + 1, fx + n + 1) - fx - 1;
  sort(fy + 1, fy + n + 1), my = unique(fy + 1, fy + n + 1) - fy - 1;
  for (int i = 1; i <= n; ++i)
    X[i] = lower_bound(fx + 1, fx + mx + 1, X[i]) - fx;
  for (int i = 1; i <= n; ++i)
    Y[i] = lower_bound(fy + 1, fy + my + 1, Y[i]) - fy;
  for (int i = 1; i <= n; ++i) ++rx[X[i]], ++ry[Y[i]];
  for (int i = 1; i <= mx; ++i) ux[i] = rx[i];
  for (int i = 1; i <= my; ++i) uy[i] = ry[i];
  for (int i = 1; i <= m; ++i) {
    int o = (read() - 1) ^ bj, l = read(), d = read();
    if (!o) {
      int x = lower_bound(fx + 1, fx + mx + 1, l) - fx;
      if (fx[x] != l) continue;
      ckmax(dx[x], (rx[x] - d + 1) >> 1), ckmin(ux[x], (rx[x] + d) >> 1);
    } else {
      int y = lower_bound(fy + 1, fy + my + 1, l) - fy;
      if (fy[y] != l) continue;
      ckmax(dy[y], (ry[y] - d + 1) >> 1), ckmin(uy[y], (ry[y] + d) >> 1);
    }
  }
  int S = mx + my + 1, T = S + 1;
  for (int i = 1; i <= mx; ++i) {
    if (ux[i] < dx[i])
      return puts("-1"), 0;
    else
      Add(S, i, ux[i] - dx[i]);
  }
  for (int i = 1; i <= n; ++i) Add(X[i], mx + Y[i], 1), P[i] = cnt;
  for (int i = 1; i <= my; ++i) {
    if (uy[i] < dy[i])
      return puts("-1"), 0;
    else
      Add(i + mx, T, uy[i] - dy[i]);
  }
  memcpy(rh, h, sizeof(int) * (T + 1));
  int RS = T + 1, RT = RS + 1, SR = 0, TR = 0;
  for (int i = 1; i <= mx; ++i) Add(RS, i, dx[i]), SR += dx[i];
  for (int i = 1; i <= my; ++i) Add(i + mx, RT, dy[i]), TR += dy[i];
  Add(S, RT, SR), Add(RS, T, TR), Add(T, S, INF);
  int res = 0;
  E = RT, memcpy(cur, h, sizeof(int) * (E + 1));
  while (Bfs(RS))
    res += Dfs(RS, 1 << 30), memcpy(h, cur, sizeof(int) * (E + 1));
  if (res < SR + TR) return puts("-1"), 0;
  memcpy(h, rh, sizeof(int) * (T + 1));
  E = T, memcpy(cur, h, sizeof(int) * (E + 1));
  while (Bfs(S)) res += Dfs(S, 1 << 30), memcpy(h, cur, sizeof(int) * (E + 1));
  long long Ans = 0;
  for (int i = 1; i <= n; ++i) P[i] = vl[P[i]], Ans += P[i] ? R : B;
  cout << Ans << "\n";
  for (int i = 1; i <= n; ++i) putchar(P[i] ^ bj ? 'r' : 'b');
  return 0;
}