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>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx,avx2")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 2e5 + 5, M = 5e5 + 5;
int h[N], en = 1, n, m, need[N], tot, d[N], s, t, eid[N], S, T, mi[N], cnt[N],
          idn, rc, bc, xy[N];
map<int, int> numx, numy;
bool changeflag;
struct edge {
  int n, v, w;
} e[M << 1];
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) {
  need[y] += l;
  need[x] -= l;
  exadd(x, y, r - l);
}
bool bfs(int s, int aim) {
  queue<int> q;
  q.push(s);
  memset(d, 0, sizeof d);
  d[s] = 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 s, int t) {
  int res = 0;
  while (bfs(s, t)) res += dfs(s, INT_MAX, t);
  return res;
}
signed main() {
  read(n);
  read(m);
  read(rc);
  read(bc);
  if (rc > bc) swap(rc, bc), changeflag = 1;
  for (int i = 1, x, y; i <= n; i++) {
    read(x);
    read(y);
    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, x, v;
    read(op);
    read(x);
    read(v);
    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);
    }
  }
  s = idn + 1;
  t = s + 1;
  S = 0;
  T = t + 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 write(-1), 0;
    if (!xy[i])
      lradd(s, i, l, r);
    else
      lradd(i, t, l, r);
  }
  for (int i = S + 1; i <= T - 1; i++) {
    if (need[i] < 0) exadd(i, T, -need[i]);
    if (need[i] > 0) exadd(S, i, need[i]), tot += need[i];
  }
  exadd(t, s, INT_MAX);
  if (dinic(S, T) ^ tot) return write(-1), 0;
  int ans = dinic(s, t);
  write(1ll * ans * rc + 1ll * (n - ans) * bc);
  puts("");
  for (int i = 1; i <= n; i++) {
    if (e[eid[i]].w ^ changeflag)
      putchar('r');
    else
      putchar('b');
  }
}