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;
const int N = 200010;
int n, m, S, T, tot, cnt = 1, lim[N], h[N], lst[N], in[N], wid[N];
struct edge {
  int to, next, w;
} e[N * 20];
void addedge(int x, int y, int z) {
  e[++cnt] = (edge){y, h[x], z};
  h[x] = cnt;
}
void insert(int x, int y, int z) {
  addedge(x, y, z);
  addedge(y, x, 0);
}
map<int, int> Id;
vector<pair<int, int> > G[N];
vector<int> Idx, Idy;
int d[N];
bool bfs(int st, int ed) {
  memset(d, 0, sizeof(d));
  queue<int> Q;
  Q.push(st);
  d[st] = 1;
  while (Q.size()) {
    int x = Q.front();
    Q.pop();
    for (int i = h[x]; i; i = e[i].next) {
      int y = e[i].to;
      if (e[i].w && !d[y]) d[y] = d[x] + 1, Q.push(y);
    }
  }
  return d[ed] > 0;
}
int dfs(int x, int ed, int maxf) {
  if (x == ed || !maxf) return maxf;
  int flow = 0;
  for (int& i = lst[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (!e[i].w || d[y] != d[x] + 1) continue;
    int w = dfs(y, ed, min(maxf, e[i].w));
    flow += w;
    maxf -= w;
    e[i].w -= w;
    e[i ^ 1].w += w;
    if (!maxf) break;
  }
  return flow;
}
int dinic(int st, int ed) {
  int ans = 0;
  while (bfs(st, ed)) {
    memcpy(lst, h, sizeof(lst));
    ans += dfs(st, ed, 1e9);
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  int r, b;
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    y = -y;
    if (!Id.count(x)) Id[x] = ++tot, Idx.push_back(tot);
    if (!Id.count(y)) Id[y] = ++tot, Idy.push_back(tot);
    int idx = Id[x], idy = Id[y];
    G[idx].push_back(make_pair(idy, i));
    G[idy].push_back(make_pair(idx, i));
  }
  for (int i = 1; i <= tot; i++) lim[i] = 1e9;
  for (int i = 1; i <= m; i++) {
    int t, l, D;
    scanf("%d%d%d", &t, &l, &D);
    if (t == 1)
      lim[Id[l]] = min(lim[Id[l]], D);
    else
      lim[Id[-l]] = min(lim[Id[-l]], D);
  }
  S = 0;
  T = ++tot;
  for (int i = 0; i < Idx.size(); i++) {
    int id = Idx[i];
    lim[id] = min(lim[id], int(G[id].size()));
    int l = (int(G[id].size()) - lim[id] + 1) / 2,
        r = (G[id].size() + lim[id]) / 2;
    if (l > r) puts("-1"), exit(0);
    in[S] -= l;
    in[id] += l;
    insert(S, id, r - l);
    for (int j = 0; j < G[id].size(); j++) {
      insert(id, G[id][j].first, 1);
      wid[G[id][j].second] = cnt;
    }
  }
  for (int i = 0; i < Idy.size(); i++) {
    int id = Idy[i];
    lim[id] = min(lim[id], int(G[id].size()));
    int l = (G[id].size() - lim[id] + 1) / 2, r = (G[id].size() + lim[id]) / 2;
    if (l > r) puts("-1"), exit(0);
    in[id] -= l;
    in[T] += l;
    insert(id, T, r - l);
  }
  int st = ++tot, ed = ++tot, tmp = cnt;
  for (int i = 0; i <= tot - 2; i++)
    if (in[i] > 0)
      insert(st, i, in[i]);
    else if (in[i] < 0)
      insert(i, ed, -in[i]);
  insert(T, S, 1e9);
  int edge_id = cnt;
  dinic(st, ed);
  for (int i = h[st]; i; i = e[i].next)
    if (e[i].w) puts("-1"), exit(0);
  for (int i = h[ed]; i; i = e[i].next)
    if (e[i ^ 1].w) puts("-1"), exit(0);
  for (int x = 0; x <= tot; x++)
    while (h[x] > tmp) h[x] = e[h[x]].next;
  int ans = e[edge_id].w + dinic(S, T);
  cout << 1ll * ans * min(r, b) + 1ll * (n - ans) * max(r, b) << "\n";
  bool flag = (r > b);
  for (int i = 1; i <= n; i++) cout << ((e[wid[i]].w ^ flag) ? "r" : "b");
}