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 inf = 1 << 28;
const int maxn = 600005;
struct edge {
  int u, v, lim, vol, next;
} edg[maxn];
int ehead[maxn], ecnt = 1;
int x[maxn], y[maxn], deg[maxn];
int discx[maxn], cntx;
int discy[maxn], cnty;
int ver[maxn], hor[maxn];
int limx[maxn], limy[maxn];
int du[maxn], S, T, sS, sT, cnt, edgid[maxn];
int n, m, r, b;
void add(int u, int v, int lim, int vol) {
  edg[++ecnt] = (edge){u, v, lim, vol, ehead[u]};
  ehead[u] = ecnt;
  edg[++ecnt] = (edge){v, u, 0, 0, ehead[v]};
  ehead[v] = ecnt;
}
namespace dinic {
int lab[maxn];
int que[maxn], head, tail;
int dfs(int u, int t, int cur) {
  if (u == t) return cur;
  int res = 0;
  for (int v, j = ehead[u]; j && res < cur; j = edg[j].next)
    if (edg[j].vol && lab[v = edg[j].v] == lab[u] + 1) {
      int tmp = dfs(v, t, min(cur - res, edg[j].vol));
      res += tmp;
      edg[j].vol -= tmp;
      edg[j ^ 1].vol += tmp;
    }
  if (!res) lab[u] = -1;
  return res;
}
int bfs(int s, int t) {
  memset(lab, -1, (cnt + 1) * sizeof(int));
  head = tail = 0;
  que[head] = s;
  lab[s] = 0;
  while (head <= tail) {
    int u = que[head++];
    for (int v, j = ehead[u]; j; j = edg[j].next)
      if (edg[j].vol && lab[v = edg[j].v] == -1) {
        lab[v] = lab[u] + 1;
        que[++tail] = v;
      }
  }
  return lab[t] != -1;
}
int dinic(int s, int t) {
  int res = 0;
  while (bfs(s, t)) res += dfs(s, t, inf);
  return res;
}
void lim_dinic() {
  for (int i = 2; i <= ecnt; i += 2) {
    du[edg[i].u] -= edg[i].lim;
    du[edg[i].v] += edg[i].lim;
    edg[i].vol -= edg[i].lim;
  }
  int oecnt = ecnt, sum = 0;
  for (int i = 1; i <= T; i++) {
    if (du[i] > 0) add(sS, i, 0, du[i]), sum += du[i];
    if (du[i] < 0) add(i, sT, 0, -du[i]);
  }
  add(T, S, 0, inf);
  if (sum != dinic(sS, sT)) {
    puts("-1");
    return;
  }
  int ans = edg[ecnt].vol;
  for (int i = oecnt + 1; i <= ecnt; i++) edg[i].vol = 0;
  ans -= dinic(T, S);
  printf("%I64d\n",
         (long long)ans * max(r, b) + (long long)(n - ans) * min(r, b));
  for (int i = 1; i <= n; i++)
    if (edg[edgid[i] ^ 1].vol)
      printf("%c", r < b ? 'b' : 'r');
    else
      printf("%c", r < b ? 'r' : 'b');
}
}  // namespace dinic
int findp(int *disc, int cnt, int num) {
  int lb = 1, rb = cnt + 1;
  while (rb - lb > 1) {
    int mid = lb + rb >> 1;
    if (disc[mid] <= num)
      lb = mid;
    else
      rb = mid;
  }
  return lb;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &r, &b);
  cnt = 0;
  for (int i = 1; i <= n; i++)
    scanf("%d %d", &x[i], &y[i]), discx[i] = x[i], discy[i] = y[i];
  sort(discx + 1, discx + n + 1);
  cntx = 1;
  sort(discy + 1, discy + n + 1);
  cnty = 1;
  for (int i = 2; i <= n; i++)
    if (discx[i] != discx[cntx]) discx[++cntx] = discx[i];
  for (int i = 2; i <= n; i++)
    if (discy[i] != discy[cnty]) discy[++cnty] = discy[i];
  for (int i = 1; i <= cntx; i++) ver[i] = ++cnt;
  for (int i = 1; i <= cnty; i++) hor[i] = ++cnt;
  S = ++cnt;
  T = ++cnt;
  sS = ++cnt;
  sT = ++cnt;
  for (int i = 1; i <= n; i++) {
    int _x = ver[findp(discx, cntx, x[i])];
    int _y = hor[findp(discy, cnty, y[i])];
    add(_x, _y, 0, 1);
    edgid[i] = ecnt - 1;
    deg[_x]++;
    deg[_y]++;
  }
  for (int i = 1; i <= cntx; i++) limx[i] = inf;
  for (int i = 1; i <= cnty; i++) limy[i] = inf;
  for (int t, l, d, i = 1; i <= m; i++) {
    scanf("%d %d %d", &t, &l, &d);
    if (t == 1) {
      int _x = findp(discx, cntx, l);
      if (_x <= 0 || _x > cntx || discx[_x] != l) continue;
      limx[_x] = min(limx[_x], d);
    } else {
      int _y = findp(discy, cnty, l);
      if (_y <= 0 || _y > cnty || discy[_y] != l) continue;
      limy[_y] = min(limy[_y], d);
    }
  }
  for (int i = 1; i <= cntx; i++) {
    int L = max(0, (deg[ver[i]] - limx[i] + 1) / 2);
    int R = (deg[ver[i]] + limx[i]) / 2;
    if (L > R) {
      puts("-1");
      return 0;
    }
    add(S, ver[i], L, R);
  }
  for (int i = 1; i <= cnty; i++) {
    int L = max(0, (deg[hor[i]] - limy[i] + 1) / 2);
    int R = (deg[hor[i]] + limy[i]) / 2;
    if (L > R) {
      puts("-1");
      return 0;
    }
    add(hor[i], T, L, R);
  }
  dinic::lim_dinic();
  return 0;
}