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 n, m, r, b, w[100001], h[100001], sw[100001], sh[100001], s, t, S, T, ns,
    nt, last[100001 * 2], dis[100001 * 2], cur[100001 * 2], cnt, num[100001],
    mn[100001 * 2], mx[100001 * 2];
long long deg[100001 * 2];
struct edge {
  int to, next;
  long long c;
} e[100001 * 30];
struct data {
  int x, y;
} a[100001];
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() {
  queue<int> q;
  for (int i = s; i <= T; i++) dis[i] = 0;
  dis[ns] = 1;
  q.push(ns);
  while (!q.empty()) {
    int u = q.front();
    q.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 true;
        q.push(e[i].to);
      }
  }
  return false;
}
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, 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, 1e15);
  }
  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;
  }
  sort(w + 1, w + n + 1);
  int w1 = unique(w + 1, w + n + 1) - w - 1;
  sort(h + 1, h + n + 1);
  int h1 = unique(h + 1, h + n + 1) - h - 1;
  s = 0;
  t = w1 + h1 + 1;
  for (int i = 1; i <= n; i++) {
    int x = lower_bound(w + 1, w + w1 + 1, a[i].x) - w;
    int y = 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 = 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] = max(mx[p], l1);
      mn[p] = min(mn[p], l2);
    } else {
      int p = 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] = max(mx[p + w1], l1);
      mn[p + w1] = min(mn[p + w1], l2);
    }
  }
  for (int i = 1; i <= w1; i++) {
    deg[s] -= mx[i];
    deg[i] += mx[i];
    addedge(s, i, 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, min(sh[i - w1], mn[i]) - mx[i]);
  }
  int tcnt = cnt;
  S = t + 1;
  T = t + 2;
  addedge(t, s, 1e15);
  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++) {
    if (e[num[i]].c)
      ans += min(b, r);
    else
      ans += 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');
}