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;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int NN = 1e5 + 10, N = 2e5 + 10, M = 10 * NN, Z = 1e9 + 7,
          ms63 = 0x3f3f3f3f;
int n, m;
long long r, b;
int x[NN], y[NN];
int ox[NN], oy[NN];
int limx[NN], limy[NN];
int numx[NN], numy[NN];
int ST, ED;
int first[N];
int id;
int w[M], cap[M], nxt[M];
void ins(int x, int y, int cap_) {
  w[++id] = y;
  cap[id] = cap_;
  nxt[id] = first[x];
  first[x] = id;
  w[++id] = x;
  cap[id] = 0;
  nxt[id] = first[y];
  first[y] = id;
}
int d[N];
bool bfs() {
  memset(d, -1, sizeof(d));
  queue<int> q;
  q.push(ST);
  d[ST] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int z = first[x]; z; z = nxt[z])
      if (cap[z]) {
        int y = w[z];
        if (d[y] == -1) {
          d[y] = d[x] + 1;
          q.push(y);
          if (y == ED) return 1;
        }
      }
  }
  return 0;
}
int dfs(int x, int all) {
  if (x == ED) return all;
  int use = 0;
  for (int z = first[x]; z; z = nxt[z])
    if (cap[z]) {
      int y = w[z];
      if (d[y] == d[x] + 1) {
        int tmp = dfs(y, min(cap[z], all - use));
        cap[z] -= tmp;
        cap[z ^ 1] += tmp;
        use += tmp;
        if (use == all) break;
      }
    }
  if (use == 0) d[x] = -1;
  return use;
}
int dinic() {
  int ret = 0;
  while (bfs()) ret += dfs(ST, ms63);
  return ret;
}
int IN[N], bot[N], top[N];
char anss[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(first, 0, sizeof(first));
    id = 1;
    scanf("%lld%lld", &r, &b);
    bool swp = 0;
    if (r > b) swap(r, b), swp = 1;
    for (int i = 1; i <= n; ++i) {
      scanf("%d%d", &x[i], &y[i]);
      ox[i] = x[i];
      oy[i] = y[i];
    }
    sort(ox + 1, ox + n + 1);
    int gx = unique(ox + 1, ox + n + 1) - ox - 1;
    for (int i = 1; i <= gx; ++i) limx[i] = 1e9, numx[i] = 0;
    sort(oy + 1, oy + n + 1);
    int gy = unique(oy + 1, oy + n + 1) - oy - 1;
    for (int i = 1; i <= gy; ++i) limy[i] = 1e9, numy[i] = 0;
    for (int i = 1; i <= n; ++i) {
      x[i] = lower_bound(ox + 1, ox + gx + 1, x[i]) - ox;
      y[i] = lower_bound(oy + 1, oy + gy + 1, y[i]) - oy;
      ++numx[x[i]];
      ++numy[y[i]];
      ins(x[i], gx + y[i], 1);
    }
    ST = 0;
    ED = gx + gy + 3;
    int ST_ = gx + gy + 1;
    int ED_ = gx + gy + 2;
    for (int i = 1; i <= m; ++i) {
      int op, p, lim;
      scanf("%d%d%d", &op, &p, &lim);
      if (op == 1) {
        int pp = lower_bound(ox + 1, ox + gx + 1, p) - ox;
        if (pp <= gx && ox[pp] == p) gmin(limx[pp], lim);
      } else {
        int pp = lower_bound(oy + 1, oy + gy + 1, p) - oy;
        if (pp <= gy && oy[pp] == p) gmin(limy[pp], lim);
      }
    }
    bool ok = 1;
    memset(IN, 0, sizeof(IN));
    for (int i = 1; i <= gx; ++i) {
      bot[i] = max(0, (numx[i] - limx[i] + 1) / 2);
      top[i] = (numx[i] + limx[i]) / 2;
      if (top[i] < bot[i]) {
        ok = 0;
        break;
      }
      ins(ST_, i, top[i] - bot[i]);
      IN[ST_] -= bot[i];
      IN[i] += bot[i];
    }
    for (int i = 1; i <= gy; ++i) {
      bot[gx + i] = max(0, (numy[i] - limy[i] + 1) / 2);
      top[gx + i] = (numy[i] + limy[i]) / 2;
      if (top[gx + i] < bot[gx + i]) {
        ok = 0;
        break;
      }
      ins(gx + i, ED_, top[gx + i] - bot[gx + i]);
      IN[gx + i] -= bot[gx + i];
      IN[ED_] += bot[gx + i];
    }
    if (!ok) {
      puts("-1");
      continue;
    }
    int sum = 0;
    for (int i = 1; i <= gx + gy + 2; ++i) {
      if (IN[i] > 0) ins(ST, i, IN[i]), sum += IN[i];
      if (IN[i] < 0) ins(i, ED, -IN[i]);
    }
    ins(ED_, ST_, 1e9);
    int flow = dinic();
    if (flow != sum) {
      puts("-1");
      continue;
    }
    ST = ST_;
    ED = ED_;
    dinic();
    int rnum = 0;
    for (int i = 1; i <= n; ++i) {
      rnum += cap[i << 1 | 1] > 0;
      anss[i] = (swp ^ (cap[i << 1 | 1] > 0)) ? 'r' : 'b';
    }
    long long ans = rnum * r + (n - rnum) * b;
    printf("%lld\n", ans);
    anss[n + 1] = 0;
    puts(anss + 1);
  }
  return 0;
}