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;
template <class T>
inline void init(T& x) {
  x = 0;
  char ch = getchar();
  bool t = 0;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') t = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + (ch - 48);
  if (t) x = -x;
  return;
}
const int N = 2e5 + 100;
const int M = 6e5;
const int INF = 1e9;
struct edge {
  int to, next, cap;
} a[M << 1];
int head[N], cnt = 0;
int s, t;
int S, T;
inline void add(int x, int y, int z) {
  a[cnt] = (edge){y, head[x], z};
  head[x] = cnt++;
}
inline void add_edge(int x, int y, int z) { add(x, y, z), add(y, x, 0); }
int n, m;
map<int, int> idH;
int cntH = 0;
map<int, int> idR;
int cntR = 0;
int Numx[N], Numy[N];
int X[N], Y[N];
int r, b;
int Lx[N], Rx[N];
int Ly[N], Ry[N];
int F[N], Std[N], d[N], cur[N];
queue<int> Q;
int dfs(int u, int flow) {
  if (u == T) return flow;
  int res = flow;
  for (int v, &i = cur[u]; ~i; i = a[i].next) {
    v = a[i].to;
    if (d[v] != d[u] + 1 || !a[i].cap) continue;
    int f = dfs(v, min(a[i].cap, res));
    res -= f;
    if (!f) d[v] = 0;
    a[i].cap -= f, a[i ^ 1].cap += f;
    if (!res) break;
  }
  return flow - res;
}
bool bfs() {
  for (int i = 1; i <= T; ++i) d[i] = 0;
  while (!Q.empty()) Q.pop();
  Q.push(S);
  d[S] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int v, i = head[u]; ~i; i = a[i].next) {
      v = a[i].to;
      if (!a[i].cap || d[v]) continue;
      d[v] = d[u] + 1;
      if (v == T) return 1;
      Q.push(v);
    }
  }
  return d[T];
}
int Dinic() {
  if (S != 0) d[0] = d[T + 1] = INF;
  int ans = 0;
  memcpy(cur, head, sizeof(cur));
  while (bfs()) {
    for (int i = 0; i <= T; ++i) cur[i] = head[i];
    ans += dfs(S, INF);
  }
  return ans;
}
int main() {
  memset(head, -1, sizeof(head));
  init(n), init(m);
  char cr = 'r', cb = 'b';
  init(r), init(b);
  if (r < b) swap(r, b), swap(cr, cb);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    init(x), init(y);
    int idx, idy;
    if (!idH.count(x))
      idH[x] = idx = ++cntH;
    else
      idx = idH[x];
    if (!idR.count(y))
      idR[y] = idy = ++cntR;
    else
      idy = idR[y];
    ++Numx[idx], ++Numy[idy];
    X[i] = idx, Y[i] = idy;
  }
  s = cntH + cntR + 1, t = s + 1;
  S = 0, T = t + 1;
  for (int i = 1; i <= n; ++i) Std[i] = cnt, add_edge(X[i], Y[i] + cntH, 1);
  for (int i = 1; i <= cntH; ++i) Lx[i] = 0, Rx[i] = n;
  for (int i = 1; i <= cntR; ++i) Ly[i] = 0, Ry[i] = n;
  for (int i = 1; i <= m; ++i) {
    int t, l, d;
    init(t), init(l), init(d);
    if (t == 1) {
      if (!idH.count(l)) {
        --i, --m;
        continue;
      }
      int id = idH[l], num = Numx[id];
      if (num <= d) {
        --i, --m;
        continue;
      }
      Lx[id] = max(Lx[id], (num - d + 1) >> 1);
      Rx[id] = min(Rx[id], (num + d) >> 1);
    } else {
      if (!idR.count(l)) {
        --i, --m;
        continue;
      }
      int id = idR[l], num = Numy[id];
      if (num <= d) {
        --i, --m;
        continue;
      }
      Ly[id] = max(Ly[id], (num - d + 1) >> 1);
      Ry[id] = min(Ry[id], (num + d) >> 1);
      id += cntH;
    }
  }
  add_edge(t, s, INF);
  int sumx = 0, sumy = 0;
  for (int i = 1; i <= cntH; ++i) {
    if (Lx[i] > Rx[i]) return puts("-1"), 0;
    add_edge(s, i, Rx[i] - Lx[i]);
    sumx += Lx[i];
    add_edge(S, i, Lx[i]);
  }
  add_edge(s, T, sumx);
  for (int i = 1; i <= cntR; ++i) {
    if (Ly[i] > Ry[i]) return puts("-1"), 0;
    add_edge(i + cntH, t, Ry[i] - Ly[i]);
    add_edge(i + cntH, T, Ly[i]);
    sumy += Ly[i];
  }
  add_edge(S, t, sumy);
  int fl = 0;
  if ((fl = Dinic()) == sumx + sumy) {
    S = s, T = t;
    Dinic();
    long long cost = 0;
    for (int i = 1; i <= n; ++i)
      if (!a[Std[i]].cap)
        cost += b;
      else
        cost += r;
    cout << cost << endl;
    for (int i = 1; i <= n; ++i)
      if (!a[Std[i]].cap)
        putchar(cb);
      else
        putchar(cr);
    puts("");
  } else
    puts("-1");
  return 0;
}