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>
const int N = 100005;
const long long inf = (long long)1e15;
int n, m, r, b, w[N], h[N], sw[N], sh[N], s, t, S, T, ns, nt, last[N * 2],
    dis[N * 2], cur[N * 2], cnt, num[N], mn[N * 2], mx[N * 2];
long long deg[N * 2];
struct edge {
  int to, next;
  long long c;
} e[N * 30];
std::queue<int> que;
struct data {
  int x, y;
} a[N];
void addedge(int u, int v, long long c) {
  e[++cnt].to = v;
  e[cnt].c = c;
  e[cnt].next = last[u];
  last[u] = cnt;
  e[++cnt].to = u;
  e[cnt].c = 0;
  e[cnt].next = last[v];
  last[v] = cnt;
}
bool bfs() {
  for (int i = s; i <= T; i++) dis[i] = 0;
  while (!que.empty()) que.pop();
  dis[ns] = 1;
  que.push(ns);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = last[u]; i; i = e[i].next)
      if (e[i].c && !dis[e[i].to]) {
        dis[e[i].to] = dis[u] + 1;
        if (e[i].to == nt) return 1;
        que.push(e[i].to);
      }
  }
  return 0;
}
long long dfs(int x, long long maxf) {
  if (x == nt || !maxf) return maxf;
  int ret = 0;
  for (int &i = cur[x]; i; i = e[i].next)
    if (e[i].c && dis[e[i].to] == dis[x] + 1) {
      long long f = dfs(e[i].to, std::min(e[i].c, maxf - ret));
      e[i].c -= f;
      e[i ^ 1].c += f;
      ret += f;
      if (maxf == ret) break;
    }
  return ret;
}
long long dinic() {
  long long ans = 0;
  while (bfs()) {
    for (int i = s; i <= T; i++) cur[i] = last[i];
    ans += dfs(ns, inf);
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  cnt = 1;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y), w[i] = a[i].x, h[i] = a[i].y;
  std::sort(w + 1, w + n + 1);
  int w1 = std::unique(w + 1, w + n + 1) - w - 1;
  std::sort(h + 1, h + n + 1);
  int h1 = std::unique(h + 1, h + n + 1) - h - 1;
  s = 0;
  t = w1 + h1 + 1;
  for (int i = 1; i <= n; i++) {
    int x = std::lower_bound(w + 1, w + w1 + 1, a[i].x) - w;
    int y = std::lower_bound(h + 1, h + h1 + 1, a[i].y) - h;
    sw[x]++;
    sh[y]++;
    addedge(x, y + w1, 1);
    num[i] = cnt;
  }
  for (int i = 1; i <= w1 + h1; i++) mn[i] = n, mx[i] = 0;
  for (int i = 1; i <= m; i++) {
    int ty, l, d;
    scanf("%d%d%d", &ty, &l, &d);
    if (ty == 1) {
      int p = std::lower_bound(w + 1, w + w1 + 1, l) - w;
      if (w[p] != l || d >= sw[p]) continue;
      int l1 = (sw[p] - d + 1) / 2, l2 = sw[p] - l1;
      if (l1 > l2) {
        puts("-1");
        return 0;
      }
      mx[p] = std::max(mx[p], l1);
      mn[p] = std::min(mn[p], l2);
    } else {
      int p = std::lower_bound(h + 1, h + h1 + 1, l) - h;
      if (h[p] != l || d >= sh[p]) continue;
      int l1 = (sh[p] - d + 1) / 2, l2 = sh[p] - l1;
      if (l1 > l2) {
        puts("-1");
        return 0;
      }
      mx[p + w1] = std::max(mx[p + w1], l1);
      mn[p + w1] = std::min(mn[p + w1], l2);
    }
  }
  for (int i = 1; i <= w1; i++)
    deg[s] -= mx[i], deg[i] += mx[i],
        addedge(s, i, std::min(sw[i], mn[i]) - mx[i]);
  for (int i = w1 + 1; i <= w1 + h1; i++)
    deg[t] += mx[i], deg[i] -= mx[i],
        addedge(i, t, std::min(sh[i - w1], mn[i]) - mx[i]);
  int tcnt = cnt;
  S = t + 1;
  T = t + 2;
  addedge(t, s, inf);
  long long sum = 0;
  for (int i = s; i <= t; i++)
    if (deg[i] < 0)
      addedge(i, T, -deg[i]);
    else if (deg[i] > 0)
      addedge(S, i, deg[i]), sum += deg[i];
  ns = S;
  nt = T;
  if (dinic() != sum) {
    puts("-1");
    return 0;
  }
  for (int i = tcnt + 1; i <= cnt; i++) e[i].c = 0;
  ns = s;
  nt = t;
  dinic();
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    ans += e[num[i]].c ? std::min(b, r) : std::max(b, r);
  printf("%I64d\n", ans);
  for (int i = 1; i <= n; i++)
    if (e[num[i]].c)
      putchar(r > b ? 'b' : 'r');
    else
      putchar(r > b ? 'r' : 'b');
  return 0;
}