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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXM = 100000;
const int GMAXN = 4 + 2 * MAXN;
const int GMAXM = 2 * (5 * MAXN + 2);
typedef struct G {
  int n, m, s, t;
  int ghead[GMAXN], gnxt[GMAXM], gto[GMAXM];
  int lcap[GMAXM], cap[GMAXM], flow[GMAXM], cur[GMAXN];
  int d[GMAXN];
  int q[GMAXN], qhead, qtail;
  void init(int _n) {
    n = _n;
    for (int i = (0); i < (n); ++i) ghead[i] = -1;
  }
  int addedge(int a, int b, int l, int h) {
    gnxt[m] = ghead[a], ghead[a] = m, gto[m] = b, lcap[m] = l, cap[m] = h - l,
    flow[m] = 0, ++m;
    gnxt[m] = ghead[b], ghead[b] = m, gto[m] = a, lcap[m] = 0, cap[m] = 0,
    flow[m] = 0, ++m;
    return m - 2;
  }
  int lmaxflow(int _s, int _t) {
    int nn = n, mm = m, ss = n++, tt = n++, want = 0;
    ghead[ss] = ghead[tt] = -1;
    for (int at = (0); at < (nn); ++at) {
      int sum = 0;
      for (int x = ghead[at]; x != -1; x = gnxt[x])
        sum += lcap[x] - lcap[x ^ 1];
      if (sum > 0) addedge(at, tt, 0, sum), want += sum;
      if (sum < 0) addedge(ss, at, 0, -sum);
    }
    int retid = addedge(_t, _s, 0, INT_MAX);
    int now = maxflow(ss, tt);
    if (now != want) return -1;
    int ret = flow[retid];
    n = nn, m = mm;
    for (int i = (0); i < (n); ++i)
      while (ghead[i] != -1 && ghead[i] >= m) ghead[i] = gnxt[ghead[i]];
    ret += maxflow(_s, _t);
    return ret;
  }
  int maxflow(int _s, int _t) {
    s = _s, t = _t;
    int ret = 0;
    while (true) {
      bfs();
      if (d[t] == INT_MAX) return ret;
      for (int i = (0); i < (n); ++i) cur[i] = ghead[i];
      int now = dfs(s, INT_MAX);
      ret += now;
    }
  }
  void bfs() {
    for (int i = (0); i < (n); ++i) d[i] = INT_MAX;
    qhead = qtail = 0;
    d[s] = 0, q[qhead++] = s;
    while (qtail < qhead) {
      int at = q[qtail++];
      for (int x = ghead[at]; x != -1; x = gnxt[x])
        if (cap[x] > flow[x]) {
          int to = gto[x];
          if (d[to] == INT_MAX) d[to] = d[at] + 1, q[qhead++] = to;
        }
    }
  }
  int dfs(int at, int left, int dd = 0) {
    if (at == t) return left;
    int ret = 0;
    for (int x = cur[at]; x != -1; x = cur[at] = gnxt[cur[at]])
      if (cap[x] > flow[x] && d[at] + 1 == d[gto[x]]) {
        int now = dfs(gto[x], min(left, cap[x] - flow[x]), dd + 1);
        flow[x] += now;
        flow[x ^ 1] -= now;
        left -= now;
        ret += now;
        if (left == 0) return ret;
      }
    return ret;
  }
} G;
int n, m;
int r, b;
int x[MAXN], y[MAXN], id[MAXN];
int qxy[MAXM], qidx[MAXM], qmxdiff[MAXM];
int xx[MAXN], nxx;
int yy[MAXN], nyy;
int degx[MAXN], degy[MAXN], lx[MAXN], hx[MAXN], ly[MAXN], hy[MAXN];
G g;
void input() {
  scanf("%d%d%d%d", &n, &m, &r, &b);
  for (int i = (0); i < (n); ++i) scanf("%d%d", &x[i], &y[i]);
  for (int i = (0); i < (m); ++i)
    scanf("%d%d%d", &qxy[i], &qidx[i], &qmxdiff[i]);
}
void solve() {
  char rc = 'r', bc = 'b';
  if (r > b) swap(r, b), swap(rc, bc);
  nxx = 0;
  for (int i = (0); i < (n); ++i) xx[nxx++] = x[i];
  sort(xx, xx + nxx);
  nxx = unique(xx, xx + nxx) - xx;
  for (int i = (0); i < (n); ++i) x[i] = lower_bound(xx, xx + nxx, x[i]) - xx;
  nyy = 0;
  for (int i = (0); i < (n); ++i) yy[nyy++] = y[i];
  sort(yy, yy + nyy);
  nyy = unique(yy, yy + nyy) - yy;
  for (int i = (0); i < (n); ++i) y[i] = lower_bound(yy, yy + nyy, y[i]) - yy;
  for (int i = (0); i < (nxx); ++i) degx[i] = 0;
  for (int i = (0); i < (n); ++i) ++degx[x[i]];
  for (int i = (0); i < (nxx); ++i) lx[i] = 0, hx[i] = degx[i];
  for (int i = (0); i < (nyy); ++i) degy[i] = 0;
  for (int i = (0); i < (n); ++i) ++degy[y[i]];
  for (int i = (0); i < (nyy); ++i) ly[i] = 0, hy[i] = degy[i];
  for (int i = (0); i < (m); ++i) {
    int xy = qxy[i], idx = qidx[i], mxdiff = qmxdiff[i];
    if (xy == 1) {
      int cx = lower_bound(xx, xx + nxx, idx) - xx;
      if (cx >= nxx || xx[cx] != idx || mxdiff >= degx[cx]) continue;
      int cl = (degx[cx] - mxdiff + 1) / 2, cr = (degx[cx] + mxdiff) / 2;
      if (cl > lx[cx]) lx[cx] = cl;
      if (cr < hx[cx]) hx[cx] = cr;
    }
    if (xy == 2) {
      int cy = lower_bound(yy, yy + nyy, idx) - yy;
      if (cy >= nyy || yy[cy] != idx || mxdiff >= degy[cy]) continue;
      int cl = (degy[cy] - mxdiff + 1) / 2, cr = (degy[cy] + mxdiff) / 2;
      if (cl > ly[cy]) ly[cy] = cl;
      if (cr < hy[cy]) hy[cy] = cr;
    }
  }
  for (int i = (0); i < (nxx); ++i)
    if (lx[i] > hx[i]) {
      printf("-1\n");
      return;
    }
  for (int i = (0); i < (nyy); ++i)
    if (ly[i] > hy[i]) {
      printf("-1\n");
      return;
    }
  int s = nxx + nyy, t = s + 1;
  g.init(nxx + nyy + 2);
  for (int i = (0); i < (nxx); ++i) g.addedge(s, i, lx[i], hx[i]);
  for (int i = (0); i < (nyy); ++i) g.addedge(nxx + i, t, ly[i], hy[i]);
  for (int i = (0); i < (n); ++i) id[i] = g.addedge(x[i], nxx + y[i], 0, 1);
  int ret = g.lmaxflow(s, t);
  if (ret == -1) {
    printf("-1\n");
    return;
  }
  printf("%lld\n", (long long)r * ret + (long long)b * (n - ret));
  for (int i = (0); i < (n); ++i) printf("%c", g.flow[id[i]] > 0 ? rc : bc);
  puts("");
}
void run() {
  input();
  solve();
}
void test() {
  n = MAXN, m = MAXM, r = 1, b = 2;
  for (int i = (0); i < (n); ++i) x[i] = rand() % 10000, y[i] = rand() % 10000;
  for (int i = (0); i < (m); ++i)
    qxy[i] = rand() % 2 + 1, qidx[i] = rand() % 10000,
    qmxdiff[i] = 1 + rand() % 10;
  solve();
}
int main() {
  run();
  return 0;
}