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 MAXN = (1 << 20);
template <class FlowT>
struct max_flow {
  const static FlowT finf = 1e18 + 42 + 17;
  const static FlowT feps = 0;
  struct edge {
    FlowT flow, cap;
    int idx, rev, to;
    edge() {
      flow = 0;
      cap = 0;
      rev = 0;
      idx = 0;
      to = 0;
    }
    edge(int _to, int _rev, FlowT _flow, FlowT _cap, int _idx) {
      to = _to;
      rev = _rev;
      flow = _flow;
      cap = _cap;
      idx = _idx;
    }
  };
  vector<edge> G[MAXN];
  int n, dist[MAXN], po[MAXN];
  bool bfs(int s, int t) {
    dist[s] = -1, po[s] = 0;
    dist[t] = -1, po[t] = 0;
    for (int v = 0; v <= n; v++) dist[v] = -1, po[v] = 0;
    queue<int> Q;
    Q.push(s);
    dist[s] = 0;
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      for (edge e : G[u])
        if (dist[e.to] == -1 && e.flow < e.cap) {
          dist[e.to] = dist[u] + 1;
          Q.push(e.to);
        }
    }
    return dist[t] != -1;
  }
  FlowT dfs(int u, int t, FlowT fl = finf) {
    if (u == t) return fl;
    for (; po[u] < G[u].size(); po[u]++) {
      auto &e = G[u][po[u]];
      if (dist[e.to] == dist[u] + 1 && e.flow < e.cap) {
        FlowT f = dfs(e.to, t, min(fl, e.cap - e.flow));
        e.flow += f;
        G[e.to][e.rev].flow -= f;
        if (f > 0) return f;
      }
    }
    return 0;
  }
  void init(int _n) { n = _n; }
  void add_edge(int u, int v, FlowT w, int idx = -1) {
    G[u].push_back(edge(v, G[v].size(), 0, w, idx));
    G[v].push_back(edge(u, G[u].size() - 1, 0, 0, -1));
  }
  FlowT flow(int s, int t) {
    if (s == t) return finf;
    FlowT ret = 0, to_add;
    while (bfs(s, t))
      while (to_add = dfs(s, t)) ret += to_add;
    return ret;
  }
};
int n, m;
max_flow<int64_t> mf;
pair<int64_t, int64_t> a[MAXN];
int64_t r, b;
void read() {
  cin >> n >> m;
  cin >> r >> b;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
}
vector<int64_t> all_idx;
map<int64_t, int64_t> low, high, cnt;
int ans[MAXN];
void solve() {
  for (int i = 0; i < n; i++) {
    all_idx.push_back(a[i].first);
    all_idx.push_back(1e9 + 42ll + a[i].second);
    cnt[a[i].first]++;
    cnt[a[i].second + 42ll + 1e9]++;
    high[a[i].first]++;
    high[a[i].second + 42ll + 1e9]++;
  }
  for (int i = 0; i < m; i++) {
    int t, l, d;
    cin >> t >> l >> d;
    if (t == 2) l += 1e9 + 42;
    all_idx.push_back(l);
    int64_t lo = (cnt[l] - d + 1) / 2, hi = (cnt[l] + d) / 2;
    lo = max(lo, (int64_t)0ll);
    hi = min(hi, cnt[l]);
    if (!low.count(l))
      low[l] = lo;
    else
      low[l] = max(low[l], lo);
    if (!high.count(l))
      high[l] = hi;
    else
      high[l] = min(high[l], hi);
  }
  sort(all_idx.begin(), all_idx.end());
  all_idx.erase(unique(all_idx.begin(), all_idx.end()), all_idx.end());
  mf.init(all_idx.size() + 42);
  for (int i = 0; i < n; i++) {
    int x = lower_bound(all_idx.begin(), all_idx.end(), (int64_t)a[i].first) -
            all_idx.begin();
    int y = lower_bound(all_idx.begin(), all_idx.end(),
                        (int64_t)a[i].second + 1e9 + 42ll) -
            all_idx.begin();
    mf.add_edge(x, y, 1, i);
  }
  int s = all_idx.size() + 1, t = all_idx.size() + 2, S = MAXN - 1,
      T = MAXN - 2;
  int64_t sum_low = 0;
  mf.add_edge(t, s, mf.finf);
  for (int i = 0; i < all_idx.size(); i++) {
    int64_t P = all_idx[i];
    if (low[P] > high[P]) {
      cout << -1 << '\n';
      return;
    }
    if (P >= 1e9 + 42ll) {
      mf.add_edge(i, t, high[P] - low[P]);
      mf.add_edge(i, T, low[P]);
      mf.add_edge(S, t, low[P]);
    } else {
      mf.add_edge(s, i, high[P] - low[P]);
      mf.add_edge(S, i, low[P]);
      mf.add_edge(s, T, low[P]);
    }
    sum_low += low[P];
  }
  if (mf.flow(S, T) != sum_low) {
    cout << -1 << '\n';
    return;
  }
  int swap_letters = 0;
  if (r > b) swap_letters = 1;
  mf.flow(s, t);
  int64_t res = 0;
  for (int u = 0; u <= mf.n; u++)
    for (auto e : mf.G[u])
      if (e.idx != -1) {
        ans[e.idx] = e.flow ^ swap_letters;
        if (ans[e.idx])
          res += r;
        else
          res += b;
      }
  cout << res << '\n';
  for (int i = 0; i < n; i++)
    if (ans[i])
      cout << "r";
    else
      cout << "b";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}