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 = 100100, M = 1001000, oo = 1000000000;
int i, j, k, n, m, nx, ny, s, t, S, T, ch, r, b, En, tmp, x, y, ans, sum;
int c[N << 1], d[N << 1], h[N << 1], in[N << 1], out[N << 1], X[N], Y[N],
    numx[N], numy[N], lx[N], rx[N], ly[N], ry[N];
struct edge {
  int s, n, v;
} E[M];
struct cc {
  int x, y;
} A[N];
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
void W(long long x) {
  if (x >= 10) W(x / 10);
  putchar(x % 10 + '0');
}
void E_add(int x, int y, int v) {
  E[++En].s = y;
  E[En].v = v;
  E[En].n = h[x];
  h[x] = En;
  E[++En].s = x;
  E[En].v = 0;
  E[En].n = h[y];
  h[y] = En;
}
void E_add(int x, int y, int up, int down) {
  E_add(x, y, down - up);
  sum += up;
  in[y] += up;
  out[x] += up;
}
int findx(int x) {
  int l = 1, r = nx, mid;
  while (l < r) {
    mid = (l + r - 1) >> 1;
    if (X[mid] < x)
      l = mid + 1;
    else
      r = mid;
  }
  if (X[l] != x) return 0;
  return l;
}
int findy(int x) {
  int l = 1, r = ny, mid;
  while (l < r) {
    mid = (l + r - 1) >> 1;
    if (Y[mid] < x)
      l = mid + 1;
    else
      r = mid;
  }
  if (Y[l] != x) return 0;
  return l;
}
bool bfs() {
  int i, j, k;
  for (i = 1; i <= T; i++) c[i] = 0;
  i = 0;
  j = 1;
  c[S] = 1;
  d[1] = S;
  while (i < j) {
    i++;
    for (k = h[d[i]]; k; k = E[k].n)
      if (E[k].v && !c[E[k].s]) {
        c[E[k].s] = c[d[i]] + 1;
        d[++j] = E[k].s;
      }
  }
  return c[T];
}
int min(int x, int y) {
  if (x < y) return x;
  return y;
}
int max(int x, int y) {
  if (x < y) return y;
  return x;
}
int dfs(int x, int y) {
  if (x == T || !y) return y;
  int k, t, Y = y;
  for (k = h[x]; k; k = E[k].n)
    if (E[k].v && c[x] + 1 == c[E[k].s]) {
      t = dfs(E[k].s, min(E[k].v, y));
      y -= t;
      E[k].v -= t;
      E[k ^ 1].v += t;
      if (!y) return Y;
    }
  if (y == Y) c[x] = -1;
  return Y - y;
}
int main() {
  R(n);
  R(m);
  R(r);
  R(b);
  En = 1;
  for (i = 1; i <= n; i++) {
    R(A[i].x);
    R(A[i].y);
    X[++nx] = A[i].x;
    Y[++ny] = A[i].y;
  }
  sort(X + 1, X + nx + 1);
  X[nx + 1] = -1;
  tmp = 0;
  for (i = 1; i <= nx; i++)
    if (X[i] != X[i + 1]) X[++tmp] = X[i];
  nx = tmp;
  sort(Y + 1, Y + ny + 1);
  Y[ny + 1] = -1;
  tmp = 0;
  for (i = 1; i <= ny; i++)
    if (Y[i] != Y[i + 1]) Y[++tmp] = Y[i];
  ny = tmp;
  for (i = 1; i <= n; i++) {
    A[i].x = findx(A[i].x);
    numx[A[i].x]++;
    A[i].y = findy(A[i].y);
    numy[A[i].y]++;
    E_add(A[i].x, nx + A[i].y, 1);
  }
  s = nx + ny + 1;
  t = s + 1;
  S = t + 1;
  T = S + 1;
  for (i = 1; i <= nx; i++) lx[i] = 0, rx[i] = numx[i];
  for (i = 1; i <= ny; i++) ly[i] = 0, ry[i] = numy[i];
  for (i = 1; i <= m; i++) {
    R(tmp);
    R(x);
    R(y);
    if (tmp == 1) {
      x = findx(x);
      if (!x) continue;
      lx[x] = max(lx[x], (numx[x] - y + 1) / 2);
      rx[x] = min(rx[x], (numx[x] + y) / 2);
    } else {
      x = findy(x);
      if (!x) continue;
      ly[x] = max(ly[x], (numy[x] - y + 1) / 2);
      ry[x] = min(ry[x], (numy[x] + y) / 2);
    }
  }
  for (i = 1; i <= nx; i++) {
    if (lx[i] > rx[i]) {
      puts("-1");
      return 0;
    }
    E_add(s, i, lx[i], rx[i]);
  }
  for (i = 1; i <= ny; i++) {
    if (ly[i] > ry[i]) {
      puts("-1");
      return 0;
    }
    E_add(nx + i, t, ly[i], ry[i]);
  }
  for (i = 1; i <= t; i++) {
    if (in[i]) E_add(S, i, in[i]);
    if (out[i]) E_add(i, T, out[i]);
  }
  E_add(t, s, oo);
  while (bfs()) ans += dfs(S, oo);
  if (ans != sum) {
    puts("-1");
    return 0;
  }
  E[En].v = E[En ^ 1].v = 0;
  S = s;
  T = t;
  while (bfs()) dfs(S, oo);
  ans = 0;
  for (i = 1; i <= n; i++)
    if (!E[i << 1].v) ans++;
  if (r < b) {
    W((long long)ans * r + (long long)(n - ans) * b);
    puts("");
    for (i = 1; i <= n; i++) {
      if (!E[i << 1].v)
        putchar('r');
      else
        putchar('b');
    }
  } else {
    W((long long)ans * b + (long long)(n - ans) * r);
    puts("");
    for (i = 1; i <= n; i++) {
      if (!E[i << 1].v)
        putchar('b');
      else
        putchar('r');
    }
  }
  puts("");
}