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;
namespace MF {
const long long wEPS = 0;
const long long wINF = 1001001001001001001;
int n, m, ptr[252521], next[1919191], zu[1919191];
int from[1919191], id[1919191];
long long capa[1919191], tof;
int lev[252521], see[252521], que[252521], *qb, *qe;
void init(int _n) {
  n = _n;
  m = 0;
  memset(ptr, ~0, n * 4);
  memset(id, -1, sizeof(id));
  tof = 0;
}
void ae(int u, int v, long long w0, int Id = -1) {
  from[m] = u;
  id[m] = Id;
  next[m] = ptr[u];
  ptr[u] = m;
  zu[m] = v;
  capa[m] = w0;
  ++m;
  from[m] = v;
  next[m] = ptr[v];
  ptr[v] = m;
  zu[m] = u;
  capa[m] = 0;
  ++m;
}
long long augment(int src, int ink, long long flo) {
  if (src == ink) return flo;
  long long f;
  for (int &i = see[src]; ~i; i = next[i])
    if (capa[i] > wEPS && lev[src] < lev[zu[i]]) {
      if ((f = augment(zu[i], ink, min(flo, capa[i]))) > wEPS) {
        capa[i] -= f;
        capa[i ^ 1] += f;
        return f;
      }
    }
  return 0;
}
bool solve(int src, int ink, long long flo = wINF) {
  long long f;
  int i, u, v;
  for (; tof + wEPS < flo;) {
    qb = qe = que;
    memset(lev, ~0, n * 4);
    for (lev[ *qe++ = src] = 0, see[src] = ptr[src]; qb != qe;) {
      for (i = ptr[u = *qb++]; ~i; i = next[i])
        if (capa[i] > wEPS && !~lev[v = zu[i]]) {
          lev[ *qe++ = v] = lev[u] + 1;
          see[v] = ptr[v];
          if (v == ink) goto au;
        }
    }
    return 0;
  au:
    for (; (f = augment(src, ink, flo - tof)) > wEPS; tof += f)
      ;
  }
  return 1;
}
}  // namespace MF
int x[114514], y[114514], numx[114514], numy[114514], dix[114514], diy[114514];
vector<int> dx, dy;
map<int, int> ex, ey;
int main() {
  int n, m, t, l, d, r, b, w = 0, inf = 114514;
  scanf("%d %d", &n, &m);
  scanf("%d %d", &r, &b);
  if (r > b) swap(r, b), w = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x[i], &y[i]);
    dx.push_back(x[i]);
    dy.push_back(y[i]);
  }
  sort(dx.begin(), dx.end());
  dx.erase(unique(dx.begin(), dx.end()), dx.end());
  sort(dy.begin(), dy.end());
  dy.erase(unique(dy.begin(), dy.end()), dy.end());
  for (int i = 0; i < dx.size(); i++) ex[dx[i]] = i;
  for (int i = 0; i < dy.size(); i++) ey[dy[i]] = i;
  for (int i = 0; i < n; i++) {
    x[i] = ex[x[i]];
    y[i] = ey[y[i]];
    numx[x[i]]++;
    numy[y[i]]++;
  }
  int X = dx.size(), Y = dy.size();
  for (int i = 0; i < X; i++) dix[i] = inf;
  for (int i = 0; i < Y; i++) diy[i] = inf;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &t, &l, &d);
    if (t == 1) {
      if (ex.find(l) != ex.end()) dix[ex[l]] = min(dix[ex[l]], d);
    } else {
      if (ey.find(l) != ey.end()) diy[ey[l]] = min(diy[ey[l]], d);
    }
  }
  int S = X + Y, T = S + 1, S2 = T + 1, T2 = S2 + 1;
  long long tmi = 0;
  MF::init(X + Y + 4);
  for (int i = 0; i < X; i++) {
    if (numx[i] % 2 > 0 && dix[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    int ma = min(numx[i], (numx[i] + dix[i]) / 2), mi = numx[i] - ma;
    MF::ae(S, i, ma - mi);
    MF::ae(S2, i, mi);
    MF::ae(S, T2, mi);
    tmi += mi;
  }
  for (int i = 0; i < Y; i++) {
    if (numy[i] % 2 > 0 && diy[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    int ma = min(numy[i], (numy[i] + diy[i]) / 2), mi = numy[i] - ma;
    MF::ae(X + i, T, ma - mi);
    MF::ae(S2, T, mi);
    MF::ae(X + i, T2, mi);
    tmi += mi;
  }
  for (int i = 0; i < n; i++) MF::ae(x[i], X + y[i], 1, i);
  MF::ae(T, S, 1145141919810364364LL);
  MF::solve(S2, T2);
  MF::solve(S, T);
  string out(n, '?'), rb = "rb";
  long long tof = 0;
  int num = 0;
  for (int i = 0; i < MF::m; i++) {
    if (MF::id[i] >= 0) {
      out[MF::id[i]] = rb[(MF::capa[i] + w) % 2];
      tof += 1LL - MF::capa[i];
      num++;
      if (MF::id[i] >= n || MF::capa[i] < 0 || MF::capa[i] > 1)
        cerr << i << endl;
    }
    if ((MF::from[i] == S2 || MF::zu[i] == T2) && MF::capa[i] > 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << tof * r + (n - tof) * b << endl;
  cout << out << endl;
}