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;
int n, m, s, t, r, b;
const int maxn = 3e5 + 5;
const int maxm = 1e6 + 5;
struct edge {
  int to, nex, w;
} e[maxm];
int cur[maxn], head[maxn], cnt = 1;
int dis[maxn];
map<int, int> idx, idy;
int num[maxn], xy[maxn], edg[maxn];
int tot;
int d[maxn], mn[maxn];
void add(int a, int b, int c) {
  e[++cnt] = (edge){b, head[a], c};
  head[a] = cnt;
}
void addedge(int a, int b, int c) { add(a, b, c), add(b, a, 0); }
void adde(int a, int b, int l, int r) {
  addedge(a, b, r - l);
  d[a] -= l, d[b] += l;
}
int bfs() {
  queue<int> Q;
  for (int i = 0; i <= tot + 3; ++i) dis[i] = 0;
  for (int i = 0; i <= tot + 3; ++i) cur[i] = head[i];
  dis[s] = 1;
  Q.push(s);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = head[u]; i; i = e[i].nex) {
      int v = e[i].to;
      if (e[i].w && !dis[v]) {
        dis[v] = dis[u] + 1;
        Q.push(v);
      }
    }
  }
  return dis[t];
}
int dfs(int u, int in) {
  if (u == t) return in;
  int out = 0;
  for (int i = cur[u]; i; i = e[i].nex) {
    int v = e[i].to;
    cur[u] = i;
    if (e[i].w && dis[v] == dis[u] + 1) {
      int tmp = dfs(v, min(in, e[i].w));
      e[i].w -= tmp, e[i ^ 1].w += tmp;
      in -= tmp, out += tmp;
      if (!in) break;
    }
  }
  if (!out) dis[u] = 0;
  return out;
}
int tag;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m >> r >> b;
  if (r > b) swap(r, b), tag = 1;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    if (!idx[x]) idx[x] = ++tot, mn[tot] = 1e9;
    ++num[idx[x]];
    if (!idy[y]) idy[y] = ++tot, mn[tot] = 1e9, xy[tot] = 1;
    ++num[idy[y]];
    addedge(idx[x], idy[y], 1);
    edg[i] = cnt;
  }
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) {
      b = idx[b];
      if (!b) continue;
      mn[b] = min(mn[b], c);
    } else {
      b = idy[b];
      if (!b) continue;
      mn[b] = min(mn[b], c);
    }
  }
  s = 0, t = tot + 1;
  for (int i = 1; i <= tot; ++i) {
    int x = num[i], y = min(mn[i], x);
    int l = (x - y + 1) / 2, r = (x + y) / 2;
    if (l > r) cout << -1 << '\n', exit(0);
    if (xy[i])
      adde(i, t, l, r);
    else
      adde(s, i, l, r);
  }
  addedge(t, s, 1e9);
  s = tot + 2, t = tot + 3;
  int sum = 0;
  for (int i = 0; i <= tot + 1; ++i) {
    if (d[i] > 0) addedge(s, i, d[i]), sum += d[i];
    if (d[i] < 0) addedge(i, t, -d[i]);
  }
  while (bfs()) sum -= dfs(s, 1e9);
  if (sum) cout << -1 << '\n', exit(0);
  s = 0, t = tot + 1;
  while (bfs()) sum += dfs(s, 1e9);
  cout << 1ll * sum * r + 1ll * (n - sum) * b << '\n';
  for (int i = 1; i <= n; ++i) {
    if (e[edg[i]].w ^ tag)
      cout << "r";
    else
      cout << "b";
  }
  return 0;
}