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 T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
struct FlowEdge {
  int v, u;
  long long cap, flow = 0;
  FlowEdge(int v, int u, long long cap) : v(v), u(u), cap(cap) {}
};
struct Dinic {
  const long long flow_inf = 1e18;
  vector<FlowEdge> edges;
  vector<vector<int>> adj;
  int n, m = 0;
  int s, t;
  vector<int> level, ptr;
  queue<int> q;
  Dinic(int n) : n(n), s(0), t(0) {
    adj.resize(n);
    level.resize(n);
    ptr.resize(n);
  }
  void clear() {
    fill(level.begin(), level.end(), 0);
    fill(ptr.begin(), ptr.end(), 0);
    for (FlowEdge &e : edges) e.flow = 0;
  }
  int add_edge(int v, int u, long long cap) {
    edges.emplace_back(v, u, cap);
    edges.emplace_back(u, v, 0);
    adj[v].push_back(m);
    adj[u].push_back(m + 1);
    m += 2;
    return m - 2;
  }
  bool bfs() {
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int id : adj[v]) {
        if (edges[id].cap - edges[id].flow < 1) continue;
        if (level[edges[id].u] != -1) continue;
        level[edges[id].u] = level[v] + 1;
        q.push(edges[id].u);
      }
    }
    return level[t] != -1;
  }
  long long dfs(int v, long long pushed) {
    if (pushed == 0) return 0;
    if (v == t) return pushed;
    for (int &cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
      int id = adj[v][cid];
      int u = edges[id].u;
      if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
        continue;
      long long tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
      if (tr == 0) continue;
      edges[id].flow += tr;
      edges[id ^ 1].flow -= tr;
      return tr;
    }
    return 0;
  }
  long long flow(int s, int t) {
    this->s = s;
    this->t = t;
    long long f = 0;
    while (true) {
      fill(level.begin(), level.end(), -1);
      level[s] = 0;
      q.push(s);
      if (!bfs()) break;
      fill(ptr.begin(), ptr.end(), 0);
      while (long long pushed = dfs(s, flow_inf)) {
        f += pushed;
      }
    }
    return f;
  }
};
int x[N];
int y[N];
int deg_x[N];
int deg_y[N];
int lx[N];
int ux[N];
int ly[N];
int uy[N];
int edge_id[N];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, r, b;
  cin >> n >> m >> r >> b;
  vector<int> all_x, all_y;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    all_x.push_back(x[i]);
    all_y.push_back(y[i]);
  }
  sort(all_x.begin(), all_x.end()),
      all_x.erase(unique(all_x.begin(), all_x.end()), all_x.end());
  sort(all_y.begin(), all_y.end()),
      all_y.erase(unique(all_y.begin(), all_y.end()), all_y.end());
  for (int i = 0; i < n; i++) {
    x[i] = lower_bound(all_x.begin(), all_x.end(), x[i]) - all_x.begin(),
    deg_x[x[i]]++, ux[x[i]]++;
    y[i] = lower_bound(all_y.begin(), all_y.end(), y[i]) - all_y.begin(),
    deg_y[y[i]]++, uy[y[i]]++;
  }
  int tx = all_x.size();
  int ty = all_y.size();
  for (int i = 0; i < m; i++) {
    int t, l, d;
    cin >> t >> l >> d;
    if (t == 1) {
      auto it = lower_bound(all_x.begin(), all_x.end(), l);
      if (it == all_x.end() or *it != l) continue;
      assert(*it == l);
      l = it - all_x.begin();
      lx[l] = max(lx[l], (deg_x[l] - d + 1) / 2);
      ux[l] = min(ux[l], (deg_x[l] + d) / 2);
      if (lx[l] > ux[l]) {
        cout << "-1\n";
        return 0;
      }
    } else {
      auto it = lower_bound(all_y.begin(), all_y.end(), l);
      if (it == all_y.end() or *it != l) continue;
      l = it - all_y.begin();
      ly[l] = max(ly[l], (deg_y[l] - d + 1) / 2);
      uy[l] = min(uy[l], (deg_y[l] + d) / 2);
      if (ly[l] > uy[l]) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  Dinic g(tx + ty + 4);
  int src = tx + ty;
  int snk = src + 1;
  int asrc = snk + 1;
  int asnk = asrc + 1;
  for (int i = 0; i < n; i++) edge_id[i] = g.add_edge(x[i], tx + y[i], 1);
  long long sum_l = 0;
  for (int i = 0; i < tx; i++)
    sum_l += lx[i], g.add_edge(src, i, ux[i] - lx[i]),
        g.add_edge(asrc, i, lx[i]);
  g.add_edge(src, asnk, sum_l);
  long long ggg = sum_l;
  for (int i = 0; i < ty; i++)
    sum_l += ly[i], g.add_edge(tx + i, snk, uy[i] - ly[i]),
        g.add_edge(tx + i, asnk, ly[i]);
  g.add_edge(asrc, snk, sum_l - ggg);
  g.add_edge(snk, src, oo);
  if (g.flow(asrc, asnk) != sum_l)
    cout << "-1\n";
  else {
    (g.flow(src, snk));
    string s;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      s += ((g.edges[edge_id[i]].flow > 0) xor (r > b)) ? "r" : "b";
    }
    for (char c : s) ans += r * (c == 'r') + b * (c == 'b');
    cout << ans << "\n" << s << "\n";
  }
}