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 std::queue;
namespace FLOW {
int S, T, head[200005], iter[200005], dis[200005], top = 1;
struct edge {
  int to, fl, nxt;
} e[200005 * 5];
inline void adde(int a, int b, int fl) {
  e[++top] = edge{b, fl, head[a]}, head[a] = top;
}
inline void add(int a, int b, int fl) { adde(a, b, fl), adde(b, a, 0); }
queue<int> q;
inline void bfs(int n) {
  std::fill(dis + 1, dis + n + 1, -1);
  dis[S] = 0;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt)
      if (e[i].fl) {
        int v = e[i].to;
        if (dis[v] == -1) dis[v] = dis[u] + 1, q.push(v);
      }
  }
}
int dfs(int u, int fl) {
  if (u == T) return fl;
  int ret = 0;
  for (int &i = iter[u]; i; i = e[i].nxt)
    if (e[i].fl) {
      int v = e[i].to;
      if (dis[v] != dis[u] + 1) continue;
      int s = dfs(v, std::min(fl, e[i].fl));
      e[i].fl -= s, fl -= s, e[i ^ 1].fl += s, ret += s;
      if (!fl) break;
    }
  return ret;
}
inline int dinic(int n, int s, int t) {
  S = s, T = t;
  int ans = 0;
  while (1) {
    bfs(n);
    if (dis[t] == -1) break;
    memcpy(iter, head, sizeof(int) * (n + 1));
    ans += dfs(s, 0x3f3f3f3f);
  }
  return ans;
}
}  // namespace FLOW
using FLOW::add;
using FLOW::dinic;
using FLOW::e;
using FLOW::head;
using FLOW::top;
int n, m, r, b, x[200005], y[200005], lsx[200005], lsy[200005], cnx[200005],
    cny[200005], dx[200005], dy[200005], fs, ft, s, t, S, T;
long long ans;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  s = 2 * n + 1, t = 2 * n + 2, S = 2 * n + 3, T = 2 * n + 4;
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", x + i, y + i), lsx[i] = x[i], lsy[i] = y[i];
  std::sort(lsx + 1, lsx + n + 1);
  std::sort(lsy + 1, lsy + n + 1);
  for (int i = 1; i <= n; ++i)
    x[i] = std::lower_bound(lsx + 1, lsx + n + 1, x[i]) - lsx;
  for (int i = 1; i <= n; ++i)
    y[i] = std::lower_bound(lsy + 1, lsy + n + 1, y[i]) - lsy;
  for (int i = 1; i <= n; ++i) ++cnx[x[i]], ++cny[y[i]];
  for (int i = 1; i <= n; ++i) dx[i] = cnx[i], dy[i] = cny[i];
  for (int i = 1, t, l, d; i <= m; ++i) {
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      int tl = std::lower_bound(lsx + 1, lsx + n + 1, l) - lsx;
      if (lsx[tl] != l) continue;
      dx[tl] = std::min(dx[tl], d);
    } else {
      int tl = std::lower_bound(lsy + 1, lsy + n + 1, l) - lsy;
      if (lsy[tl] != l) continue;
      dy[tl] = std::min(dy[tl], d);
    }
  }
  ans = 1ll * n * r;
  for (int i = 1; i <= n; ++i) add(x[i], y[i] + n, 1);
  for (int i = 1; i <= n; ++i) {
    if (!dx[i] && (cnx[i] & 1)) return puts("-1"), 0;
    if (!dy[i] && (cny[i] & 1)) return puts("-1"), 0;
    add(s, i, dx[i] - ((dx[i] ^ cnx[i]) & 1));
    add(i + n, t, dy[i] - ((dy[i] ^ cny[i]) & 1));
    add(S, i, (cnx[i] - dx[i] + 1) >> 1);
    fs += (cnx[i] - dx[i] + 1) >> 1;
    add(i + n, T, (cny[i] - dy[i] + 1) >> 1);
    ft += (cny[i] - dy[i] + 1) >> 1;
  }
  add(s, T, fs);
  add(S, t, ft);
  add(t, s, 0x3f3f3f3f);
  dinic(T, S, T);
  for (int i = head[S]; i; i = e[i].nxt)
    if (e[i].fl) return puts("-1"), 0;
  int cur = e[top].fl;
  e[top].fl = e[top ^ 1].fl = 0;
  if (r > b)
    ans -= 1ll * (r - b) * (cur + dinic(T, s, t));
  else
    ans += 1ll * (b - r) * (cur - dinic(T, t, s));
  printf("%lld\n", ans);
  for (int i = 1; i <= n; ++i)
    if (!e[i << 1].fl)
      putchar('b');
    else
      putchar('r');
  return 0;
}