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(200009);
struct LnkNode {
  int v, w, nxt;
} edge[N << 3];
int etot = 1, fst[N], cur[N];
void addedge_(int u, int v, int w) {
  ++etot;
  edge[etot].v = v;
  edge[etot].w = w;
  edge[etot].nxt = fst[u];
  fst[u] = etot;
}
void addedge(int u, int v, int w) { addedge_(u, v, w), addedge_(v, u, 0); }
void deledge_(int u) { fst[u] = edge[fst[u]].nxt; }
int n, m, r, b, x[N], y[N], cntx[N], cnty[N], x_[N], y_[N], limx[N], limy[N],
    dt[N], mf, d[N], q[N], Head, Tail;
bool bfs(int s, int t) {
  memset(d + 1, 0x3f, ((n << 1) + 4) << 2);
  Head = Tail = 0;
  d[q[Tail++] = s] = 0;
  while (Head ^ Tail) {
    int &x = q[Head++];
    for (int i = fst[x]; i; i = edge[i].nxt) {
      int &y = edge[i].v, &w = edge[i].w;
      if (w && d[y] > d[x] + 1) d[q[Tail++] = y] = d[x] + 1;
    }
  }
  return d[t] != 0x3f3f3f3f;
}
int dfs(int x, int t, int f) {
  if (x == t) return f;
  int r = f;
  for (int &i = cur[x]; i; i = edge[i].nxt) {
    int &y = edge[i].v, &w = edge[i].w;
    if (w && d[y] == d[x] + 1) {
      int k = dfs(y, t, min(r, w));
      w -= k, edge[i ^ 1].w += k;
      if (!(r -= k)) break;
    }
  }
  return f - r;
}
char res[N];
int main() {
  scanf("%d%d%d%d", &n, &m, &r, &b);
  for (int i = 1; i <= n; ++i) scanf("%d%d", x + i, y + i);
  memcpy(x_ + 1, x + 1, n << 2);
  sort(x_ + 1, x_ + 1 + n);
  memcpy(y_ + 1, y + 1, n << 2);
  sort(y_ + 1, y_ + 1 + n);
  for (int i = 1; i <= n; ++i) {
    ++cntx[x[i] = lower_bound(x_ + 1, x_ + 1 + n, x[i]) - x_];
    ++cnty[y[i] = lower_bound(y_ + 1, y_ + 1 + n, y[i]) - y_];
    addedge(x[i], n + y[i], 1);
  }
  for (int i = 1; i <= n; ++i) limx[i] = limy[i] = n;
  int t, l, d;
  while (m--) {
    scanf("%d%d%d", &t, &l, &d);
    switch (t) {
      case 1: {
        int t_ = lower_bound(x_ + 1, x_ + 1 + n, l) - x_;
        if (t_ <= n && x_[t_] == l && limx[t_] > d) limx[t_] = d;
        break;
      }
      case 2: {
        int t_ = lower_bound(y_ + 1, y_ + 1 + n, l) - y_;
        if (t_ <= n && y_[t_] == l && limy[t_] > d) limy[t_] = d;
        break;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (cntx[i]) {
      int lb = (cntx[i] > limx[i]
                    ? (((cntx[i] - limx[i]) >> 1) + ((cntx[i] - limx[i]) & 1))
                    : 0),
          rb = (cntx[i] + limx[i]) >> 1;
      if (lb > rb) return puts("-1"), 0;
      dt[(n << 1) + 1] -= lb, dt[i] += lb, addedge((n << 1) + 1, i, rb - lb);
    }
    if (cnty[i]) {
      int lb = (cnty[i] > limy[i]
                    ? (((cnty[i] - limy[i]) >> 1) + ((cnty[i] - limy[i]) & 1))
                    : 0),
          rb = (cnty[i] + limy[i]) >> 1;
      if (lb > rb) return puts("-1"), 0;
      dt[n + i] -= lb, dt[(n << 1) + 2] += lb,
          addedge(n + i, (n << 1) + 2, rb - lb);
    }
  }
  for (int i = 1; i <= (n << 1) + 2; ++i) {
    if (dt[i] > 0)
      addedge((n << 1) + 3, i, dt[i]);
    else if (dt[i] < 0)
      addedge(i, (n << 1) + 4, -dt[i]);
  }
  addedge((n << 1) + 2, (n << 1) + 1, 0x7fffffff);
  int f;
  while (bfs((n << 1) + 3, (n << 1) + 4)) {
    memcpy(cur + 1, fst + 1, ((n << 1) + 4) << 2);
    while (dfs((n << 1) + 3, (n << 1) + 4, 0x7fffffff))
      ;
  }
  for (int i = fst[(n << 1) + 3]; i; i = edge[i].nxt)
    if (edge[i].w) return puts("-1"), 0;
  mf += edge[etot].w;
  deledge_((n << 1) + 1), deledge_((n << 1) + 2);
  while (bfs((n << 1) + 1, (n << 1) + 2)) {
    memcpy(cur + 1, fst + 1, ((n << 1) + 4) << 2);
    while ((f = dfs((n << 1) + 1, (n << 1) + 2, 0x7fffffff))) mf += f;
  }
  printf("%lld\n", (long long)mf * min(r, b) + (long long)(n - mf) * max(r, b));
  for (int i = 1; i <= n; ++i) putchar((edge[i << 1].w ^ (r < b)) ? 'r' : 'b');
  putchar(10);
  return 0;
}