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;
const int N = 200005;
const int mxN = 200005, mxM = 2000005, INF = 0x3f3f3f3f;
struct graph {
  int S, T;
  int base[mxN], vec[mxM], pre[mxM], tot;
  long long c[mxM];
  int d[mxN], q[mxN];
  bool vis[mxN];
  void init() {
    memset(base, 0, sizeof(base));
    tot = 1;
  }
  int link(int x, int y, long long z) {
    vec[++tot] = y;
    pre[tot] = base[x];
    base[x] = tot;
    c[tot] = z;
    vec[++tot] = x;
    pre[tot] = base[y];
    base[y] = tot;
    c[tot] = 0;
    return tot - 1;
  }
  bool bfs() {
    int head = 0, tail = 0;
    memset(d, -1, sizeof(d));
    d[S] = 0;
    q[++tail] = S;
    while (head < tail) {
      head++;
      int u = q[head];
      for (int now = base[u]; now; now = pre[now]) {
        int v = vec[now];
        if (d[v] == -1 && c[now] > 0) {
          d[v] = d[u] + 1;
          q[++tail] = v;
          if (v == T) return 1;
        }
      }
    }
    return 0;
  }
  long long dfs(int u, long long flow) {
    long long r = 0;
    if (u == T) return flow;
    for (int now = base[u]; now && r < flow; now = pre[now]) {
      int v = vec[now];
      if (c[now] > 0 && d[v] == d[u] + 1) {
        long long x = min(c[now], flow - r);
        x = dfs(v, x);
        r += x;
        c[now] -= x;
        c[now ^ 1] += x;
      }
    }
    if (!r) d[u] = -2;
    return r;
  }
  long long dinic() {
    long long ans = 0;
    while (bfs()) ans += dfs(S, INF);
    return ans;
  }
} G;
struct P {
  int x, y;
} a[N];
int mx[N], my[N], R, C;
int id[N];
int down[N], up[N];
long long in[N], out[N];
int cnt[N];
int getx(int x) { return lower_bound(mx + 1, mx + R + 1, x) - mx; }
int gety(int y) { return lower_bound(my + 1, my + C + 1, y) - my; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int r, b;
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    mx[i] = a[i].x;
    my[i] = a[i].y;
  }
  sort(mx + 1, mx + n + 1);
  R = unique(mx + 1, mx + n + 1) - (mx + 1);
  sort(my + 1, my + n + 1);
  C = unique(my + 1, my + n + 1) - (my + 1);
  for (int i = 1; i <= R + C; i++) down[i] = 0, up[i] = INF;
  G.init();
  for (int i = 1; i <= n; i++) {
    int x = getx(a[i].x);
    int y = gety(a[i].y);
    id[i] = G.link(x, R + y, 1);
    cnt[x]++;
    cnt[R + y]++;
  }
  while (m--) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    int p = l;
    if (t == 1) {
      l = getx(l);
      if (mx[l] != p) continue;
      int num = cnt[l];
      int dow = (num - d + 1) / 2, upp = (num + d) / 2;
      down[l] = max(down[l], dow);
      up[l] = min(up[l], upp);
    }
    if (t == 2) {
      l = gety(l);
      if (my[l] != p) continue;
      int num = cnt[R + l];
      int dow = (num - d + 1) / 2, upp = (num + d) / 2;
      down[R + l] = max(down[R + l], dow);
      up[R + l] = min(up[R + l], upp);
    }
  }
  for (int i = 1; i <= R + C; i++)
    if (down[i] > up[i]) {
      printf("-1\n");
      return 0;
    }
  int S = R + C + 1, T = R + C + 2;
  int SS = T + 1, TT = T + 2;
  for (int i = 1; i <= R; i++) {
    G.link(S, i, up[i] - down[i]);
    in[i] += down[i];
    out[S] += down[i];
  }
  for (int i = R + 1; i <= R + C; i++) {
    G.link(i, T, up[i] - down[i]);
    out[i] += down[i];
    in[T] += down[i];
  }
  long long maxflow = 0;
  for (int i = 1; i <= T; i++) {
    if (in[i] > out[i])
      G.link(SS, i, in[i] - out[i]), maxflow += in[i] - out[i];
    if (out[i] > in[i]) G.link(i, TT, out[i] - in[i]);
  }
  long long ret1 = 0;
  G.S = SS;
  G.T = TT;
  G.link(T, S, INF);
  ret1 = G.dinic();
  if (ret1 != maxflow) {
    printf("-1\n");
    return 0;
  }
  G.S = S;
  G.T = T;
  long long ret2 = G.dinic();
  printf("%I64d\n", ret2 * min(r, b) + (n - ret2) * max(r, b));
  for (int i = 1; i <= n; i++)
    if (G.c[id[i]] == 0)
      printf(r < b ? "r" : "b");
    else
      printf(r < b ? "b" : "r");
}