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;
struct edge {
  int to, nxt, val, pos;
} e[2000005];
struct dot {
  int x, y;
} a[200005];
struct LS {
  int x, pos;
} ls[200005];
inline bool cmp(LS aa, LS bb) { return aa.x < bb.x; }
int use[200005], cur[200005], node[200005], S, aNs[200005], T, dis[200005],
    c[200005], zz, tot = 1;
char f[10];
queue<int> q;
map<int, int> p1, p2;
inline void ADD(int x, int y, int pos, int v) {
  e[++tot].nxt = node[x];
  node[x] = tot;
  e[tot].val = v;
  e[tot].to = y;
  e[tot].pos = pos;
}
inline void add(int x, int y, int pos, int v) {
  ADD(x, y, pos, v);
  ADD(y, x, pos, 0);
}
int bfs() {
  memset(dis, -1, sizeof(dis));
  dis[S] = 0;
  q.push(S);
  int x, i;
  while (q.size()) {
    x = q.front();
    q.pop();
    for (i = node[x]; i; i = e[i].nxt)
      if (e[i].val && !~dis[e[i].to])
        dis[e[i].to] = dis[x] + 1, q.push(e[i].to);
  }
  return ~dis[T];
}
int dfs(int now, int flow) {
  if (now == T) return flow;
  int qwq, fl = 0;
  for (int &i = cur[now]; i; i = e[i].nxt) {
    if (dis[e[i].to] == dis[now] + 1 && e[i].val) {
      qwq = dfs(e[i].to, min(flow, e[i].val));
      flow -= qwq;
      fl += qwq;
      e[i].val -= qwq, e[i ^ 1].val += qwq;
      if (!flow) return fl;
    }
  }
  return fl;
}
int d[200005], j, n, cnt, D, i, R, B, nowv, x, y, s, mn[200005], t, m, gg, ans,
    cho;
int main() {
  cin >> n >> m >> R >> B;
  for (i = 1; i <= n; ++i) {
    cin >> a[i].x >> a[i].y;
    ls[i].x = a[i].x;
    ls[i].pos = i;
  }
  sort(ls + 1, ls + n + 1, cmp);
  for (i = 1; i <= n; ++i) {
    if (ls[i].x != ls[i - 1].x) p1[ls[i].x] = ++nowv;
    a[ls[i].pos].x = nowv;
    ++c[nowv];
  }
  zz = nowv;
  for (i = 1; i <= n; ++i) ls[i].x = a[i].y, ls[i].pos = i;
  sort(ls + 1, ls + n + 1, cmp);
  for (i = 1; i <= n; ++i) {
    if (ls[i].x != ls[i - 1].x) p2[ls[i].x] = ++nowv;
    a[ls[i].pos].y = nowv;
    ++c[nowv];
  }
  S = 0;
  T = nowv + 1;
  s = nowv + 2;
  t = nowv + 3;
  for (i = 1; i <= m; ++i) {
    cin >> D >> x >> y;
    if (D == 1) {
      if (p1[x]) {
        gg = p1[x];
        mn[gg] = max(mn[gg], (c[gg] - y + 1) / 2);
        if (y == 0 && (c[gg] & 1)) return cout << "-1", 0;
      }
    } else {
      if (p2[x]) {
        gg = p2[x];
        mn[gg] = max(mn[gg], (c[gg] - y + 1) / 2);
        if (y == 0 && (c[gg] & 1)) return cout << "-1", 0;
      }
    }
  }
  for (i = 1; i <= n; ++i) add(a[i].x, a[i].y, i, 1), use[i] = tot;
  gg = 0;
  for (i = 1; i <= zz; ++i) {
    d[s] += mn[i];
    d[i] -= mn[i];
    add(s, i, 0, c[i] - (mn[i] << 1));
  }
  for (i = zz + 1; i <= nowv; ++i) {
    d[i] += mn[i];
    d[t] -= mn[i];
    add(i, t, 0, c[i] - (mn[i] << 1));
  }
  add(t, s, 0, 2000000000);
  for (i = 1; i <= t; ++i) {
    if (d[i] < 0) add(S, i, 0, -d[i]);
    if (d[i] > 0) add(i, T, 0, d[i]), gg += d[i];
  }
  while (bfs()) memcpy(cur, node, sizeof(node)), ans += dfs(S, 2000000000);
  if (ans != gg)
    return cout << "-1\n", 0;
  else {
    for (i = node[S]; i; i = e[i].nxt) e[i].val = e[i ^ 1].val = 0;
    for (i = node[T]; i; i = e[i].nxt) e[i].val = e[i ^ 1].val = 0;
    S = s;
    T = t;
    while (bfs()) memcpy(cur, node, sizeof(node)), dfs(S, 2000000000);
    for (i = 1; i <= zz; ++i) {
      for (j = node[i]; j; j = e[j].nxt) {
        if (e[j].pos && !e[j].val) {
          aNs[e[j].pos] = 1;
          ++cho;
        }
      }
    }
    cout << 1ll * cho * min(R, B) + 1ll * (n - cho) * max(R, B) << "\n";
    f[1] = 'r', f[0] = 'b';
    if (R > B) swap(f[0], f[1]);
    for (i = 1; i <= n; ++i) cout << f[e[use[i]].val];
  }
}