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>
template <class T1, class T2>
inline bool cmin(T1 &a, const T2 &b) {
  return b < a ? (a = b, true) : false;
}
template <class T1, class T2>
inline bool cmax(T1 &a, const T2 &b) {
  return a < b ? (a = b, true) : false;
}
template <class Type>
Type read() {
  Type a;
  bool b;
  unsigned char c;
  while (c = getchar() - 48, (c > 9) & (c != 253))
    ;
  for (a = (b = c == 253) ? 0 : c; (c = getchar() - 48) <= 9; a = a * 10 + c)
    ;
  return b ? -a : a;
}
int (*rd)() = read<int>;
namespace G {
const int N = 2e5 + 10, M = 1e6 + 10;
int n, m, s, t, to[M], cap[M], head[N], next[M], deg[N], dis[N], cur[N];
void init(int v, int src, int dst) {
  n = v, m = 0, s = src, t = dst;
  memset(head, -1, n * sizeof(int));
  memset(deg, 0, n * sizeof(int));
}
void edge(int u, int v, int w) {
  to[m] = v, cap[m] = w, next[m] = head[u], head[u] = m++;
  to[m] = u, cap[m] = 0, next[m] = head[v], head[v] = m++;
}
void add_edge(int u, int v, int min, int max) {
  if (max > min) edge(u, v, max - min);
  deg[u] += min;
  deg[v] -= min;
}
bool bfs() {
  static int queue[N];
  int *qhead = queue, *qtail = queue;
  memset(dis, -1, n * sizeof(int));
  dis[ *qtail++ = t] = 0;
  while (qhead != qtail) {
    int u = *qhead++;
    for (int i = head[u]; ~i; i = next[i])
      if (cap[i ^ 1] && dis[to[i]] == -1) {
        dis[ *qtail++ = to[i]] = dis[u] + 1;
        if (to[i] == s) return true;
      }
  }
  return false;
}
int dfs(int u, int lim) {
  if (u == t) return lim;
  int rem = lim;
  for (int &i = cur[u]; ~i; i = next[i])
    if (cap[i] && dis[to[i]] + 1 == dis[u]) {
      int now = dfs(to[i], std::min(cap[i], rem));
      cap[i] -= now;
      cap[i ^ 1] += now;
      if ((rem -= now) == 0) break;
    }
  return lim - rem;
}
int flow(int ss, int tt) {
  int msave = m, ans = deg[ss];
  edge(tt, ss, 1e9);
  for (int i = 0; i < n; ++i) {
    if (deg[i] < 0) edge(s, i, -deg[i]);
    if (deg[i] > 0) edge(i, t, deg[i]);
  }
  while (bfs()) {
    memcpy(cur, head, n * sizeof(int));
    dfs(s, 1e9);
  }
  for (int i = head[s]; ~i; i = next[i])
    if (cap[i]) return -1;
  for (int i = 0; i < n; ++i)
    while (~head[i] && head[i] >= msave) head[i] = next[head[i]];
  s = ss, t = tt;
  while (bfs()) {
    memcpy(cur, head, n * sizeof(int));
    dfs(s, 1e9);
  }
  for (int i = head[s]; ~i; i = next[i]) ans += cap[i ^ 1];
  return ans;
}
}  // namespace G
const int N = 1e5;
int x[N], y[N], nx, ny, rx[N], ry[N], cnt[2 * N], lim[2 * N];
char ans[N + 1];
int main() {
  int n, m, r, b;
  bool rev = false;
  n = rd(), m = rd(), r = rd(), b = rd();
  if (r > b) rev = true, std::swap(r, b);
  for (int i = 0; i < n; ++i) {
    x[i] = rx[i] = rd();
    y[i] = ry[i] = rd();
  }
  std::sort(rx, rx + n);
  nx = std::unique(rx, rx + n) - rx;
  std::sort(ry, ry + n);
  ny = std::unique(ry, ry + n) - ry;
  G::init(nx + ny + 4, nx + ny + 2, nx + ny + 3);
  for (int i = 0; i < n; ++i) {
    x[i] = std::lower_bound(rx, rx + nx, x[i]) - rx;
    y[i] = std::lower_bound(ry, ry + ny, y[i]) - ry;
    ++cnt[x[i]], ++cnt[nx + y[i]];
    G::add_edge(x[i], nx + y[i], 0, 1);
  }
  std::fill(lim, lim + nx + ny, n);
  while (m--) {
    int t = rd(), l = rd(), d = rd();
    if (t == 1) {
      int i = std::lower_bound(rx, rx + nx, l) - rx;
      if (rx[i] == l) cmin(lim[i], d);
    } else {
      int i = std::lower_bound(ry, ry + ny, l) - ry;
      if (ry[i] == l) cmin(lim[nx + i], d);
    }
  }
  for (int i = 0; i < nx + ny; ++i) {
    lim[i] -= (lim[i] + cnt[i]) & 1;
    if (lim[i] < 0) {
      puts("-1");
      return 0;
    }
    int min = std::max(0, (cnt[i] - lim[i]) / 2), max = (lim[i] + cnt[i]) / 2;
    if (i < nx)
      G::add_edge(nx + ny, i, min, max);
    else
      G::add_edge(i, nx + ny + 1, min, max);
  }
  int f = G::flow(nx + ny, nx + ny + 1);
  if (f == -1) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n; ++i) ans[i] = "rb"[rev ^ G::cap[2 * i]];
  printf("%lld\n%s\n", (long long)r * f + (long long)b * (n - f), ans);
  return 0;
}