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 MAXN = 200010;
struct Node {
  int To, Next, Flow;
  Node(void) {}
  Node(int a, int b, int c) : To(a), Next(b), Flow(c) {}
} E[MAXN * 10];
map<int, int> Hx, Hy;
bool Fal[MAXN];
int Final[MAXN], Po[MAXN][2], Lx[MAXN], Ly[MAXN], Cx[MAXN], Cy[MAXN], S, T, SS,
    TT;
int Deg[MAXN], D[MAXN], Count[MAXN], N, M, cntx, cnty, tot;
void Link(int u, int v, int f) {
  E[++tot] = Node(v, Final[u], f), Final[u] = tot;
  E[++tot] = Node(u, Final[v], 0), Final[v] = tot;
}
bool Link(int u, int v, int low, int up) {
  if (low > up) return 0;
  Link(u, TT, low), Link(SS, v, low);
  Link(u, v, up - low);
  return 1;
}
bool Illegal() {
  for (int i = Final[SS]; i; i = E[i].Next)
    if (E[i].Flow) return 1;
  return 0;
}
int CurS, CurT;
int Dfs(int Now, int Flow) {
  if (Now == CurT) return Flow;
  int Use = 0;
  for (int i = Final[Now]; i; i = E[i].Next)
    if (E[i].Flow && !Fal[E[i].To] && D[E[i].To] + 1 == D[Now]) {
      int tmp = Dfs(E[i].To, min(Flow - Use, E[i].Flow));
      E[i].Flow -= tmp, E[i ^ 1].Flow += tmp, Use += tmp;
      if (Use == Flow) return Use;
    }
  if (!(--Count[D[Now]])) D[CurS] = CurT + 1;
  ++Count[++D[Now]];
  return Use;
}
int MaxFlow(int s, int t) {
  CurS = s, CurT = t;
  for (int i = 0; i <= TT + 5; i++) D[i] = Count[i] = 0;
  Count[0] = t + 1;
  int tmp = 0;
  for (; D[s] < t + 1;) tmp += Dfs(s, 1 << 30);
  return tmp;
}
int main() {
  tot = 1;
  scanf("%d%d", &N, &M);
  int rc, bc, ch = 0;
  scanf("%d%d", &rc, &bc);
  if (rc > bc) swap(rc, bc), ch = 1;
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &Po[i][0], &Po[i][1]);
    if (!Hx[Po[i][0]]) Hx[Po[i][0]] = ++cntx;
    if (!Hy[Po[i][1]]) Hy[Po[i][1]] = ++cnty;
    Po[i][0] = Hx[Po[i][0]], Po[i][1] = Hy[Po[i][1]];
    Cx[Po[i][0]]++, Cy[Po[i][1]]++;
  }
  for (int i = 1; i <= cntx; i++) Lx[i] = Cx[i];
  for (int i = 1; i <= cnty; i++) Ly[i] = Cy[i];
  for (int i = 1; i <= M; i++) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      l = Hx[l];
      if (l) Lx[l] = min(Lx[l], d);
    } else {
      l = Hy[l];
      if (l) Ly[l] = min(Ly[l], d);
    }
  }
  for (int i = 1; i <= N; i++) Link(Po[i][0], Po[i][1] + cntx, 1);
  S = 0, T = cntx + cnty + 1, SS = T + 1, TT = SS + 1;
  for (int i = 1; i <= cntx; i++)
    if (!Link(S, i, max(0, (Cx[i] - Lx[i] + 1) / 2),
              min(Cx[i], ((Lx[i] + Cx[i]) / 2)))) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= cnty; i++)
    if (!Link(i + cntx, T, max(0, (Cy[i] - Ly[i] + 1) / 2),
              min(Cy[i], ((Ly[i] + Cy[i]) / 2)))) {
      printf("-1\n");
      return 0;
    }
  Link(T, S, 1 << 30);
  MaxFlow(SS, TT);
  if (Illegal()) {
    printf("-1\n");
    return 0;
  }
  int ans = E[Final[S]].Flow;
  Fal[SS] = Fal[TT] = 1;
  Final[T] = E[Final[T]].Next, Final[S] = E[Final[S]].Next;
  ans += MaxFlow(S, T);
  printf("%I64d\n", ans * 1ll * rc + (N - ans) * 1ll * bc);
  for (int i = 1; i <= N; i++)
    if (E[i << 1 | 1].Flow ^ ch)
      printf("r");
    else
      printf("b");
  printf("\n");
  return 0;
}