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 head[200005], nxt[2000055], v[2000055], w[2000055], tot = 1;
int lev[200005], que[200005], l = 1, r = 0, red, blue;
int x[100005], y[100005], tag[100005], pos[100005], d[100005], n, m;
int tx[100005], ty[100005], lx[100005], ly[100005];
int px[100005], py[100005], cx = 0, cy = 0, st, ed, s, t, ss, tt;
int u[200005], id[100005];
inline int getx(int p) {
  int l = 1, r = cx;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (px[mid] < p) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  if (px[l] == p) return l;
  return -1;
}
inline int gety(int p) {
  int l = 1, r = cy;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (py[mid] < p) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  if (py[l] == p) return l;
  return -1;
}
inline void add(int a, int b, int val) {
  tot++;
  nxt[tot] = head[a];
  head[a] = tot;
  v[tot] = b;
  w[tot] = val;
}
inline void adli(int a, int b, int lo, int hi) {
  if (lo > hi) {
    puts("-1");
    exit(0);
  }
  u[b] += lo;
  u[a] -= lo;
  if (lo ^ hi) {
    add(a, b, hi - lo);
    add(b, a, 0);
  }
}
inline bool bfs() {
  memset(lev, 0x7f, sizeof(lev));
  l = 1;
  r = 0;
  que[++r] = st;
  lev[st] = 0;
  while (l <= r) {
    int t = que[l++], i;
    for (i = head[t]; i; i = nxt[i]) {
      if (w[i] && lev[v[i]] > lev[t] + 1) {
        lev[v[i]] = lev[t] + 1;
        que[++r] = v[i];
      }
    }
  }
  return lev[ed] < 1000000000;
}
int dfs(int p, int t) {
  if (p == ed) return t;
  int cst = 0, i;
  for (i = head[p]; i; i = nxt[i]) {
    if (lev[v[i]] != lev[p] + 1 || (!w[i])) continue;
    int o = dfs(v[i], min(t - cst, w[i]));
    cst += o;
    w[i] -= o;
    w[i ^ 1] += o;
    if (cst == t) return t;
  }
  lev[p] = -1;
  return cst;
}
inline int dinic() {
  int flo = 0;
  while (bfs()) flo += dfs(st, 1000000000);
  return flo;
}
int main() {
  int i, rec, res = 0, gg, num = 0, tg = 0;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &red, &blue);
  if (red > blue) {
    swap(red, blue);
    tg = 1;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    px[++cx] = x[i];
    py[++cy] = y[i];
  }
  sort(px + 1, px + cx + 1);
  sort(py + 1, py + cy + 1);
  cx = unique(px + 1, px + cx + 1) - px - 1;
  cy = unique(py + 1, py + cy + 1) - py - 1;
  s = cx + cy + 1;
  t = cx + cy + 2;
  ss = cx + cy + 3;
  tt = cx + cy + 4;
  for (i = 1; i <= n; i++) {
    x[i] = getx(x[i]);
    y[i] = gety(y[i]);
    tx[x[i]]++;
    ty[y[i]]++;
  }
  for (i = 1; i <= cx; i++) lx[i] = tx[i];
  for (i = 1; i <= cy; i++) ly[i] = ty[i];
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &tag[i], &pos[i], &d[i]);
    if (tag[i] == 1) pos[i] = getx(pos[i]);
    if (tag[i] == 2) pos[i] = gety(pos[i]);
    if (pos[i] == -1) continue;
    if (tag[i] == 1) lx[pos[i]] = min(lx[pos[i]], d[i]);
    if (tag[i] == 2) ly[pos[i]] = min(ly[pos[i]], d[i]);
  }
  for (i = 1; i <= n; i++) {
    adli(x[i], y[i] + cx, 0, 1);
    id[i] = tot;
  }
  for (i = 1; i <= cx; i++)
    adli(s, i, (tx[i] - lx[i] + 1) >> 1, (tx[i] + lx[i]) >> 1);
  for (i = 1; i <= cy; i++)
    adli(i + cx, t, (ty[i] - ly[i] + 1) >> 1, (ty[i] + ly[i]) >> 1);
  rec = tot;
  add(t, s, 1000000000);
  add(s, t, 0);
  for (i = 1; i <= t; i++) {
    if (u[i] == 0) continue;
    if (u[i] > 0) {
      add(ss, i, u[i]);
      add(i, ss, 0);
      res += u[i];
    } else {
      add(i, tt, -u[i]);
      add(tt, i, 0);
    }
  }
  st = ss;
  ed = tt;
  gg = dinic();
  if (gg != res) {
    puts("-1");
    return 0;
  }
  num = w[rec + 2];
  for (i = rec + 1; i <= tot; i++) w[i] = 0;
  st = s;
  ed = t;
  num += dinic();
  printf("%lld\n", 1ll * num * red + 1ll * (n - num) * blue);
  for (i = 1; i <= n; i++) {
    if (w[id[i]]) {
      putchar(tg ? 'b' : 'r');
    } else {
      putchar(tg ? 'r' : 'b');
    }
  }
  return 0;
}