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;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (c < 48) c == '-' && (f = -1), c = getchar();
  while (c > 47) x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;
int h[MAXN], deg[MAXN], d[MAXN], eid[MAXN];
int mi[MAXN], cnt[MAXN], xy[MAXN];
int n, m, st, ed, vs, vt, tot, rc, bc, idn, en = 1;
map<int, int> numx, numy;
bool changeflag;
struct edge {
  int n, v, w;
} e[MAXN << 3];
void add(int x, int y, int z) {
  e[++en] = (edge){h[x], y, z};
  h[x] = en;
}
void exadd(int x, int y, int z) { add(x, y, z), add(y, x, 0); }
void lradd(int x, int y, int l, int r) {
  deg[y] += l;
  deg[x] -= l;
  exadd(x, y, r - l);
}
bool bfs(int st, int aim) {
  memset(d, 0, sizeof d);
  queue<int> q;
  q.push(st);
  d[st] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = h[x]; i; i = e[i].n) {
      int y = e[i].v;
      if (!d[y] && e[i].w) {
        d[y] = d[x] + 1;
        if (y == aim) return 1;
        q.push(y);
      }
    }
  }
  return 0;
}
int dfs(int x, int flow, int aim) {
  if (x == aim) return flow;
  int rest = flow;
  for (int i = h[x]; i && rest; i = e[i].n) {
    int y = e[i].v;
    if (d[y] == d[x] + 1 && e[i].w) {
      int tp = dfs(y, min(rest, e[i].w), aim);
      if (!tp) d[y] = 0;
      rest -= tp;
      e[i].w -= tp;
      e[i ^ 1].w += tp;
    }
  }
  return flow - rest;
}
int dinic(int st, int ed) {
  int res = 0;
  while (bfs(st, ed)) res += dfs(st, INT_MAX, ed);
  return res;
}
signed main() {
  n = read();
  m = read();
  rc = read();
  bc = read();
  if (rc > bc) swap(rc, bc), changeflag = 1;
  for (int i = 1, x, y; i <= n; i++) {
    x = read();
    y = read();
    if (!numx[x]) numx[x] = ++idn, mi[idn] = INT_MAX;
    cnt[numx[x]]++;
    if (!numy[y]) numy[y] = ++idn, mi[idn] = INT_MAX, xy[idn] = 1;
    cnt[numy[y]]++;
    exadd(numx[x], numy[y], 1);
    eid[i] = en;
  }
  while (m--) {
    int op = read(), x = read(), v = read();
    if (op == 1) {
      x = numx[x];
      if (!x) continue;
      mi[x] = min(mi[x], v);
    } else {
      x = numy[x];
      if (!x) continue;
      mi[x] = min(mi[x], v);
    }
  }
  st = idn + 1;
  ed = st + 1;
  vs = 0;
  vt = ed + 1;
  for (int i = 1; i <= idn; i++) {
    int c = cnt[i], d = min(mi[i], c), l = c - d + 1 >> 1, r = c + d >> 1;
    if (l > r) return puts("-1"), 0;
    if (!xy[i])
      lradd(st, i, l, r);
    else
      lradd(i, ed, l, r);
  }
  for (int i = vs + 1; i <= vt - 1; i++) {
    if (deg[i] < 0) exadd(i, vt, -deg[i]);
    if (deg[i] > 0) exadd(vs, i, deg[i]), tot += deg[i];
  }
  exadd(ed, st, INT_MAX);
  if (dinic(vs, vt) ^ tot) return puts("-1"), 0;
  int ans = dinic(st, ed);
  printf("%lld\n", 1ll * ans * rc + 1ll * (n - ans) * bc);
  for (int i = 1; i <= n; i++) {
    if (e[eid[i]].w ^ changeflag)
      putchar('r');
    else
      putchar('b');
  }
}