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 Max_N(100050);
const int INF(0X3F3F3F3F);
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io::gi;
using io::print;
using io::putc;
inline void GG() { print(-1), exit(0); }
namespace G {
const int Max_V(300000);
const int Max_E(3000000);
int V, S, T, Head[Max_V], Total, To[Max_E], Next[Max_E], Cap[Max_E],
    Flow[Max_E];
inline void Add_Edge(int tot, int s, int t, int c) {
  To[tot] = t, Next[tot] = Head[s], Head[s] = tot, Cap[tot] = c, Flow[tot] = 0;
}
inline void Add_Link(int s, int t, int c) {
  Total += 2, Add_Edge(Total, s, t, c), Add_Edge(Total ^ 1, t, s, 0);
}
int Cur[Max_V], Q[Max_V], Dist[Max_V];
bool BFS() {
  int l, r;
  for (int i = 1; i <= V; ++i) Dist[i] = 0;
  Dist[Q[l = r = 1] = S] = 1;
  for (int u; l <= r;) {
    if ((u = Q[l++]) == T) return true;
    for (int i = Head[u], v; i; i = Next[i])
      if (!Dist[v = To[i]] && Cap[i] > Flow[i]) Dist[Q[++r] = v] = Dist[u] + 1;
  }
  return false;
}
int DFS(int u, int a) {
  if (u == T || a == 0) return a;
  int Ans(0);
  for (int &i = Cur[u], v, f; i; i = Next[i])
    if (Dist[v = To[i]] == Dist[u] + 1 &&
        (f = DFS(v, min(a, Cap[i] - Flow[i]))) > 0) {
      Ans += f, Flow[i] += f, Flow[i ^ 1] -= f;
      if ((a -= f) == 0) break;
    }
  return Ans;
}
int Dinic() {
  int Ans(0);
  while (BFS()) {
    for (int i = 1; i <= V; ++i) Cur[i] = Head[i];
    Ans += DFS(S, INF);
  }
  return Ans;
}
}  // namespace G
int N, M, R, B, X[Max_N], Y[Max_N], HX[Max_N], HY[Max_N], MX[Max_N], MY[Max_N],
    CX[Max_N], CY[Max_N], Num[Max_N], S, T, Limit;
inline void Add_Link(int s, int t, int l, int r) {
  if (r - l) G::Add_Link(s, t, r - l);
  if (l) G::Add_Link(G::S, t, l), G::Add_Link(s, G::T, l), Limit += l;
}
int main() {
  gi(N), gi(M);
  gi(R), gi(B);
  for (int i = 1; i <= N; ++i)
    gi(X[i]), gi(Y[i]), HX[++HX[0]] = X[i], HY[++HY[0]] = Y[i];
  sort(HX + 1, HX + 1 + HX[0]),
      HX[0] = unique(HX + 1, HX + 1 + HX[0]) - (HX + 1);
  sort(HY + 1, HY + 1 + HY[0]),
      HY[0] = unique(HY + 1, HY + 1 + HY[0]) - (HY + 1);
  for (int x = 1; x <= HX[0]; ++x) MX[x] = N;
  for (int y = 1; y <= HY[0]; ++y) MY[y] = N;
  for (int i = 1; i <= N; ++i) {
    ++CX[X[i] = lower_bound(HX + 1, HX + 1 + HX[0], X[i]) - HX];
    ++CY[Y[i] = lower_bound(HY + 1, HY + 1 + HY[0], Y[i]) - HY];
  }
  G::V = HX[0] + HY[0] + 2 + 2, G::S = HX[0] + HY[0] + 2 + 1,
  G::T = HX[0] + HY[0] + 2 + 2;
  S = HX[0] + HY[0] + 1, T = HX[0] + HY[0] + 2;
  for (int t, l, p, d; M--;) {
    gi(t), gi(l), gi(d);
    if (t == 1) {
      if (HX[p = lower_bound(HX + 1, HX + 1 + HX[0], l) - HX] == l)
        MX[p] = min(MX[p], d);
    } else {
      if (HY[p = lower_bound(HY + 1, HY + 1 + HY[0], l) - HY] == l)
        MY[p] = min(MY[p], d);
    }
  }
  for (int x = 1, l, r; x <= HX[0]; ++x) {
    l = max(0, (CX[x] - MX[x]) / 2 - 1);
    while (l - (CX[x] - l) < -MX[x]) ++l;
    r = min((MX[x] + CX[x]) / 2 + 1, CX[x]);
    while (r - (CX[x] - r) > +MX[x]) --r;
    if (l <= r)
      Add_Link(S, x, l, r);
    else
      GG();
  }
  for (int y = 1, l, r; y <= HY[0]; ++y) {
    l = max(0, (CY[y] - MY[y]) / 2 - 1);
    while (l - (CY[y] - l) < -MY[y]) ++l;
    r = min((MY[y] + CY[y]) / 2 + 1, CY[y]);
    while (r - (CY[y] - r) > +MY[y]) --r;
    if (l <= r)
      Add_Link(HX[0] + y, T, l, r);
    else
      GG();
  }
  for (int i = 1; i <= N; ++i)
    G::Add_Link(X[i], HX[0] + Y[i], 1), Num[i] = G::Total;
  G::Add_Link(T, S, INF);
  if (G::Dinic() < Limit) GG();
  int Ans = G::Flow[G::Total];
  G::Cap[G::Total] = G::Cap[G::Total + 1] = G::Flow[G::Total] =
      G::Flow[G::Total + 1] = 0;
  Ans += (G::S = S, G::T = T, G::Dinic());
  print(max(R, B) * 1LL * N - (max(R, B) - min(R, B)) * 1LL * Ans), putc('\n');
  for (int i = 1; i <= N; ++i)
    if (G::Flow[Num[i]])
      putc(R <= B ? 'r' : 'b');
    else
      putc(R <= B ? 'b' : 'r');
  return 0;
}