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 IN() {
  int x = 0, f = 0, ch;
  for (; (ch = getchar()) < '0' || ch > '9';) f = (ch == '-');
  for (; ch >= '0' && ch <= '9'; (ch = getchar())) x = x * 10 + ch - '0';
  return f ? -x : x;
}
int N, M, C1, C2, ID[100005], Ans[100005];
int X[100005], Y[100005], LX[100005], LY[100005], RX[100005], RY[100005],
    NX[100005], NY[100005];
struct Nod {
  int x, y;
} A[100005];
namespace Flow {
int C, D, S, T, ss, tt, st[1000005], Q[1000005], Dis[1000005], G[1000005];
struct Lin {
  int v, next, f;
} E[1000005];
void Link(int u, int v, int f) {
  if (!f) return;
  E[++D] = (Lin){v, st[u], f};
  st[u] = D;
  E[++D] = (Lin){u, st[v], 0};
  st[v] = D;
}
bool BFS() {
  for (int i = 1, lim = C; i <= lim; i++) Dis[i] = -1;
  Dis[Q[1] = ss] = 0;
  for (int l = 0, r = 1; l < r;) {
    int u = Q[++l];
    for (int i = st[u], v; i; i = E[i].next)
      if (E[i].f && Dis[v = E[i].v] == -1) {
        Dis[Q[++r] = v] = Dis[u] + 1;
        if (v == tt) return 1;
      }
  }
  return 0;
}
int DFS(int u, int Lim) {
  if (u == tt) return Lim;
  int ret = 0;
  for (int i = st[u], v; i; i = E[i].next)
    if (E[i].f && Dis[u] + 1 == Dis[v = E[i].v]) {
      int t = DFS(v, min(Lim - ret, E[i].f));
      if (t) {
        E[i].f -= t;
        E[i ^ 1].f += t;
        ret += t;
        if (ret == Lim) break;
      } else
        Dis[v] = -1;
    }
  return ret;
}
bool check(int w) {
  C = *X + *Y;
  S = ++C;
  T = ++C;
  ss = ++C;
  tt = ++C;
  for (int i = 1, lim = C; i <= lim; i++) st[i] = G[i] = 0;
  D = 1;
  int tot = 0;
  for (int i = 1, lim = *X; i <= lim; i++)
    Link(S, i, RX[i]), G[S] += LX[i], G[i] -= LX[i], tot += LX[i];
  for (int i = 1, lim = *Y; i <= lim; i++)
    Link(*X + i, T, RY[i]), G[*X + i] += LY[i], G[T] -= LY[i], tot += LY[i];
  for (int i = 1, lim = N; i <= lim; i++)
    Link(A[i].x, *X + A[i].y, 1), ID[i] = D;
  Link(T, S, w);
  for (int i = 1, lim = C; i <= lim; i++) {
    if (G[i] > 0) Link(i, tt, G[i]);
    if (G[i] < 0) Link(ss, i, -G[i]);
  }
  int flow = 0;
  for (; BFS();) flow += DFS(ss, (1 << 30));
  for (int i = 1, lim = N; i <= lim; i++) Ans[i] = E[ID[i]].f;
  return flow == tot;
}
int Main() {
  int L = -1, R = N + 1;
  for (; L + 1 < R;) {
    int Mid = (L + R) >> 1;
    if (check(Mid))
      R = Mid;
    else
      L = Mid;
  }
  check(R);
  return R;
}
};  // namespace Flow
int main(int argc, char* argv[]) {
  N = IN();
  M = IN();
  C1 = IN();
  C2 = IN();
  for (int i = 1, lim = N; i <= lim; i++)
    A[i] = (Nod){IN(), IN()}, X[++*X] = A[i].x, Y[++*Y] = A[i].y;
  sort(X + 1, X + *X + 1);
  *X = unique(X + 1, X + *X + 1) - X - 1;
  sort(Y + 1, Y + *Y + 1);
  *Y = unique(Y + 1, Y + *Y + 1) - Y - 1;
  for (int i = 1, lim = N; i <= lim; i++) {
    A[i].x = lower_bound(X + 1, X + *X + 1, A[i].x) - X;
    A[i].y = lower_bound(Y + 1, Y + *Y + 1, A[i].y) - Y;
    LX[i] = LY[i] = N;
    NX[A[i].x]++;
    NY[A[i].y]++;
  }
  for (int i = 1, lim = M; i <= lim; i++) {
    int t = IN(), k = IN(), d = IN();
    if (t == 1) {
      int x = lower_bound(X + 1, X + *X + 1, k) - X;
      if (X[x] == k) LX[x] = min(LX[x], d);
    } else {
      int y = lower_bound(Y + 1, Y + *Y + 1, k) - Y;
      if (Y[y] == k) LY[y] = min(LY[y], d);
    }
  }
  int GTW = 0;
  for (int i = 1, lim = *X; i <= lim; i++) {
    int d = LX[i];
    if (d >= NX[i])
      LX[i] = 0, RX[i] = N;
    else {
      LX[i] = (NX[i] - d + 1) / 2;
      RX[i] = (NX[i] + d) / 2;
      RX[i] -= LX[i];
      if (RX[i] < 0) GTW = 1;
    }
  }
  for (int i = 1, lim = *Y; i <= lim; i++) {
    int d = LY[i];
    if (d >= NY[i])
      LY[i] = 0, RY[i] = N;
    else {
      LY[i] = (NY[i] - d + 1) / 2;
      RY[i] = (NY[i] + d) / 2;
      RY[i] -= LY[i];
      if (RY[i] < 0) GTW = 1;
    }
  }
  if (GTW) return puts("-1");
  int ret = Flow::Main();
  if (ret == N + 1)
    puts("-1");
  else {
    int flag = 0;
    if (C1 > C2) swap(C1, C2), flag = 1;
    printf("%lld\n", 1ll * C1 * (N - ret) + 1ll * C2 * ret);
    for (int i = 1, lim = N; i <= lim; i++)
      Ans[i] ^= flag, putchar(Ans[i] ? 'b' : 'r');
  }
  puts("");
  fprintf(stderr, "%d\n", ret);
  return 0;
}