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 chkmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
inline int read() {
  int sum = 0, p = 1;
  char ch = getchar();
  while (!(('0' <= ch && ch <= '9') || ch == '-')) ch = getchar();
  if (ch == '-') p = -1, ch = getchar();
  while ('0' <= ch && ch <= '9') sum = sum * 10 + ch - 48, ch = getchar();
  return sum * p;
}
const int maxn = 5e5 + 20;
const int inf = 0x3f3f3f3f;
struct node {
  int v, next, w;
};
node e[maxn << 3];
int cnt = 1, start[maxn];
inline void addedge(int u, int v, int w) {
  e[++cnt] = (node){v, start[u], w};
  start[u] = cnt;
}
inline void Addedge(int u, int v, int w) {
  addedge(u, v, w);
  addedge(v, u, 0);
}
int n, m, R, B;
int x[maxn], y[maxn];
int tot, S, T, Sn, Tn;
map<int, int> mpx, mpy;
map<int, int> mpxid, mpyid;
map<int, int> mpxnum, mpynum;
map<int, int>::iterator it;
int rkx[maxn], tpx, rky[maxn], tpy;
int sx[maxn], should;
inline void Add(int u, int v, int l, int r) {
  if (l > r) puts("-1"), exit(0);
  sx[v] += l;
  sx[u] -= l;
  Addedge(u, v, r - l);
}
inline void build() {
  for (int i = (1), _end_ = (tot); i <= _end_; i++)
    if (sx[i] > 0)
      Addedge(Sn, i, sx[i]), should += sx[i];
    else
      Addedge(i, Tn, -sx[i]);
}
int num[maxn], ok;
inline void init() {
  n = read();
  m = read();
  R = read();
  B = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) x[i] = read(), y[i] = read();
  S = ++tot;
  T = ++tot;
  Sn = ++tot;
  Tn = ++tot;
  for (int i = (1), _end_ = (m); i <= _end_; i++) {
    int op = read(), x = read(), d = read();
    if (op == 1)
      rkx[++tpx] = x;
    else
      rky[++tpy] = x;
    map<int, int> *mp = op == 1 ? &mpx : &mpy;
    if (!mp->count(x))
      (*mp)[x] = d;
    else
      chkmin((*mp)[x], d);
  }
  sort(rkx + 1, rkx + tpx + 1);
  tpx = unique(rkx + 1, rkx + tpx + 1) - rkx - 1;
  sort(rky + 1, rky + tpy + 1);
  tpy = unique(rky + 1, rky + tpy + 1) - rky - 1;
  for (it = mpx.begin(); it != mpx.end(); it++) mpxid[it->first] = ++tot;
  for (it = mpy.begin(); it != mpy.end(); it++) mpyid[it->first] = ++tot;
  for (int i = (1), _end_ = (n); i <= _end_; i++) {
    if (mpx.count(x[i])) mpxnum[x[i]]++;
    if (mpy.count(y[i])) mpynum[y[i]]++;
  }
  for (int i = (1), _end_ = (tpx); i <= _end_; i++) {
    int l = mpxnum[rkx[i]] - mpx[rkx[i]] + 1 >> 1,
        r = mpxnum[rkx[i]] + mpx[rkx[i]] >> 1;
    chkmax(l, 0);
    chkmin(r, mpxnum[rkx[i]]);
    Add(S, mpxid[rkx[i]], l, r);
  }
  for (int i = (1), _end_ = (tpy); i <= _end_; i++) {
    int l = mpynum[rky[i]] - mpy[rky[i]] + 1 >> 1,
        r = mpynum[rky[i]] + mpy[rky[i]] >> 1;
    chkmax(l, 0);
    chkmin(r, mpynum[rky[i]]);
    Add(mpyid[rky[i]], T, l, r);
  }
  for (int i = (1), _end_ = (n); i <= _end_; i++) {
    num[i] = ++tot;
    if (!mpx.count(x[i]) && !mpy.count(y[i]))
      num[i] = -1, ++ok;
    else if (mpx.count(x[i]) && mpy.count(y[i]))
      Addedge(mpxid[x[i]], num[i], 1), Addedge(num[i], mpyid[y[i]], 1);
    else if (mpx.count(x[i]))
      Addedge(mpxid[x[i]], num[i], 1), Addedge(num[i], T, 1);
    else
      Addedge(S, num[i], 1), Addedge(num[i], mpyid[y[i]], 1);
  }
  Addedge(T, S, inf);
  build();
}
int lev[maxn], cur[maxn];
int _S, _T;
inline bool bfs() {
  static queue<int> q;
  while (!q.empty()) q.pop();
  memset(lev, 0, sizeof(int) * (tot + 1));
  lev[_S] = 1;
  q.push(_S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = start[(u)]; i; i = e[i].next) {
      int v = e[i].v;
      if (!lev[v] && e[i].w) {
        lev[v] = lev[u] + 1;
        q.push(v);
        if (v == _T) return 1;
      }
    }
  }
  return 0;
}
int dfs(int u, int flow) {
  if (u == _T) return flow;
  int tag = 0;
  for (int &i = cur[u]; i; i = e[i].next) {
    int v = e[i].v;
    if (lev[v] == lev[u] + 1 && e[i].w) {
      int c = dfs(v, min(flow - tag, e[i].w));
      if (c) {
        e[i].w -= c;
        e[i ^ 1].w += c;
        tag += c;
        if (tag == flow) return tag;
      }
    }
  }
  return tag;
}
inline int max_flow(int S, int T) {
  _S = S;
  _T = T;
  int ans = 0;
  while (bfs()) {
    memcpy(cur, start, sizeof(int) * (tot + 1));
    ans += dfs(_S, inf);
  }
  return ans;
}
inline void doing() {
  int ned = max_flow(Sn, Tn);
  if (ned != should) puts("-1"), exit(0);
  int x = max_flow(S, T);
  long long ans = 1ll * (x + ok) * min(R, B) + 1ll * (n - x - ok) * max(R, B);
  printf("%lld\n", ans);
  for (int u = (1), _end_ = (n); u <= _end_; u++) {
    int goal = mpyid.count(y[u]) ? mpyid[y[u]] : T;
    if (num[u] != -1) {
      for (int i = start[(num[u])]; i; i = e[i].next)
        if (e[i].v == goal) {
          if (e[i].w == 1)
            printf("%c", R > B ? 'r' : 'b');
          else
            printf("%c", R > B ? 'b' : 'r');
        }
    } else
      printf("%c", R > B ? 'b' : 'r');
  }
}
int main() {
  init();
  doing();
  return 0;
}