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 read() {
  int s = 0, t = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * t;
}
struct edge {
  int to, lt, f;
} e[601000 << 1];
int in[201000], cnt = 1, poi;
queue<int> q;
int dis[201000];
void add(int x, int y, int f) {
  e[++cnt].to = y;
  e[cnt].lt = in[x];
  e[cnt].f = f;
  in[x] = cnt;
  e[++cnt].to = x;
  e[cnt].lt = in[y];
  e[cnt].f = 0;
  in[y] = cnt;
}
bool bfs(int s, int t) {
  while (!q.empty()) q.pop();
  memset(dis, 0, poi + 1 << 2);
  dis[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = in[x]; i; i = e[i].lt) {
      int y = e[i].to;
      if (e[i].f <= 0 || dis[y]) continue;
      dis[y] = dis[x] + 1;
      q.push(y);
      if (y == t) return 1;
    }
  }
  return 0;
}
int dfs(int x, int t, int flow) {
  if (x == t || !flow) return flow;
  int cur = flow;
  for (int i = in[x]; i; i = e[i].lt) {
    int y = e[i].to;
    if (e[i].f > 0 && dis[y] == dis[x] + 1) {
      int tmp = dfs(y, t, min(e[i].f, cur));
      cur -= tmp;
      e[i].f -= tmp;
      e[i ^ 1].f += tmp;
      if (!cur) return flow;
    }
  }
  dis[x] = -1;
  return flow - cur;
}
int dinic(int s, int t) {
  int ans = 0;
  while (bfs(s, t)) ans += dfs(s, t, 20021225);
  return ans;
}
int n, m;
int x[201000], y[201000], vx[201000], vy[201000], nx, ny, op[201000], l[201000],
    d[201000], id[201000], r, b;
int cntx[201000], cnty[201000];
int visx[201000], visy[201000], out[201000], lb[201000], rb[201000];
bool ps[201000];
int main() {
  n = read(), m = read();
  r = read(), b = read();
  for (int i = 1; i <= n; i++) vx[i] = x[i] = read(), vy[i] = y[i] = read();
  sort(vx + 1, vx + n + 1);
  sort(vy + 1, vy + n + 1);
  nx = unique(vx + 1, vx + n + 1) - vx - 1;
  ny = unique(vy + 1, vy + n + 1) - vy - 1;
  poi = nx + ny;
  bool tag = 0;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(vx + 1, vx + nx + 1, x[i]) - vx, cntx[x[i]]++,
    y[i] = lower_bound(vy + 1, vy + ny + 1, y[i]) - vy, cnty[y[i]]++;
    add(x[i], nx + y[i], 1);
    id[i] = cnt;
  }
  int s = ++poi, t = ++poi, S = ++poi, T = ++poi;
  for (int i = 1; i <= m; i++) {
    op[i] = read(), l[i] = read(), d[i] = read();
    if (op[i] == 1) {
      if (*lower_bound(vx + 1, vx + nx + 1, l[i]) == l[i]) {
        l[i] = lower_bound(vx + 1, vx + nx + 1, l[i]) - vx;
        if (!visx[l[i]] || d[i] < d[visx[l[i]]]) visx[l[i]] = i;
      } else
        ps[i] = 1;
    } else {
      if (*lower_bound(vy + 1, vy + ny + 1, l[i]) == l[i]) {
        l[i] = lower_bound(vy + 1, vy + ny + 1, l[i]) - vy;
        if (!visy[l[i]] || d[i] < d[visy[l[i]]]) visy[l[i]] = i;
      } else
        ps[i] = 1;
    }
  }
  for (int i = 1; i <= nx; i++) {
    if (visx[i]) {
      int x = visx[i];
      lb[i] = max((cntx[i] - d[x] + 1) / 2, 0);
      rb[i] = (d[x] + cntx[i]) / 2;
      out[i] -= lb[i], rb[i] -= lb[i];
      if (rb[i] < 0) tag = 1;
    } else {
      lb[i] = 0, rb[i] = 20021225;
    }
    add(s, i, rb[i]);
    out[s] += lb[i];
  }
  for (int i = 1; i <= ny; i++) {
    if (visy[i]) {
      int y = visy[i];
      lb[nx + i] = max((cnty[i] - d[y] + 1) / 2, 0);
      rb[nx + i] = (d[y] + cnty[i]) / 2;
      out[nx + i] += lb[nx + i], rb[nx + i] -= lb[nx + i];
      if (rb[nx + i] < 0) tag = 1;
    } else {
      lb[nx + i] = 0, rb[nx + i] = 20021225;
    }
    add(nx + i, t, rb[nx + i]);
    out[t] -= lb[nx + i];
  }
  int tot = 0, qwq = 0;
  for (int i = 1; i <= t; i++) {
    if (out[i] > 0) add(i, T, out[i]), tot += out[i];
    if (out[i] < 0) add(S, i, -out[i]), qwq -= out[i];
  }
  add(t, s, 20021225);
  int v = dinic(S, T);
  if (v != tot || tag) return puts("-1"), 0;
  dinic(s, t);
  int wei = 0;
  for (int i = 1; i <= n; i++)
    if (!e[id[i]].f) wei++;
  int gg = n - wei;
  printf("%lld\n", 1ll * wei * max(r, b) + 1ll * gg * min(r, b));
  for (int i = 1; i <= n; i++)
    if (!e[id[i]].f)
      if (max(r, b) == r)
        printf("r");
      else
        printf("b");
    else if (max(r, b) == r)
      printf("b");
    else
      printf("r");
  return 0;
}