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 <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename C, typename T = decay<decltype(*begin(declval<C>()))>,
          typename enable_if<!is_same<C, string>::value>::type * = nullptr>
ostream &operator<<(ostream &os, const C &c) {
  bool f = true;
  os << "[";
  for (const auto &x : c) {
    if (!f) os << ", ";
    f = false;
    os << x;
  }
  return os << "]";
}
template <typename T>
void debug(string s, T x) {
  cerr << s << " = " << x << "\n";
}
template <typename T, typename... Args>
void debug(string s, T x, Args... args) {
  for (int i = 0, b = 0; i < (int)s.size(); i++)
    if (s[i] == '(' || s[i] == '{')
      b++;
    else if (s[i] == ')' || s[i] == '}')
      b--;
    else if (s[i] == ',' && b == 0) {
      cerr << s.substr(0, i) << " = " << x << " | ";
      debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
      break;
    }
}
struct Edge {
  int u, v;
  long long cap, flow;
  Edge(int _u, int _v, long long _cap) : u(_u), v(_v), cap(_cap), flow(0) {}
};
struct Dinic {
  int m, s, t;
  vector<int> level, ptr;
  vector<Edge> edges;
  vector<vector<int>> adj;
  Dinic(int n, int _s, int _t) : m(0), s(_s), t(_t), level(n), ptr(n), adj(n) {}
  void addEdge(int u, int v, long long cap, long long rcap = 0) {
    edges.emplace_back(u, v, cap);
    edges.emplace_back(v, u, rcap);
    adj[u].push_back(m++);
    adj[v].push_back(m++);
  }
  bool bfs() {
    fill(level.begin(), level.end(), -1);
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int e : adj[u])
        if (edges[e].flow < edges[e].cap && level[edges[e].v] == -1) {
          level[edges[e].v] = level[u] + 1;
          q.push(edges[e].v);
        }
    }
    return level[t] != -1;
  }
  long long dfs(int u, long long f) {
    if (f == 0 || u == t) return f;
    while (ptr[u] < (int)adj[u].size()) {
      int e = adj[u][ptr[u]], v = edges[e].v;
      long long nf;
      if (level[u] + 1 == level[v] && edges[e].flow < edges[e].cap &&
          (nf = dfs(v, min(f, edges[e].cap - edges[e].flow))) > 0) {
        edges[e].flow += nf;
        edges[e ^ 1].flow -= nf;
        return nf;
      }
      ptr[u]++;
    }
    return 0;
  }
  long long maxFlow(long long limit = LLONG_MAX) {
    long long ret = 0;
    while (limit > 0 && bfs()) {
      fill(ptr.begin(), ptr.end(), 0);
      while (long long f = dfs(s, limit)) {
        ret += f;
        limit -= f;
      }
    }
    return ret;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, r, b;
  cin >> n >> m >> r >> b;
  vector<int> x(n), y(n);
  map<int, int> mpX, mpY;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    mpX[x[i]];
    mpY[y[i]];
  }
  vector<array<int, 3>> constr;
  for (int i = 0; i < m; i++) {
    int t, l, d;
    cin >> t >> l >> d;
    if (t == 1)
      mpX[l];
    else
      mpY[l];
    constr.push_back({t, l, d});
  }
  int id = 0;
  vector<int> side;
  for (auto &p : mpX) {
    p.second = id++;
    side.push_back(0);
  }
  for (auto &p : mpY) {
    p.second = id++;
    side.push_back(1);
  }
  int s = id, t = id + 1;
  Dinic dinic(id + 4, id + 2, id + 3);
  vector<int> deg(id);
  for (int i = 0; i < n; i++) {
    dinic.addEdge(mpX[x[i]], mpY[y[i]], 1);
    deg[mpX[x[i]]]++;
    deg[mpY[y[i]]]++;
  }
  vector<int> diff = deg;
  for (auto [tp, l, d] : constr) {
    if (tp == 1)
      diff[mpX[l]] = min(diff[mpX[l]], d);
    else
      diff[mpY[l]] = min(diff[mpY[l]], d);
  }
  vector<int> l(id), u(id);
  vector<long long> in(id + 2), out(id + 2);
  for (int i = 0; i < id; i++) {
    l[i] = max((deg[i] - diff[i] + 1) / 2, 0);
    u[i] = (deg[i] + diff[i]) / 2;
    if (l[i] > u[i]) {
      cout << "-1\n";
      return 0;
    }
    if (side[i]) {
      dinic.addEdge(i, t, u[i] - l[i]);
      in[t] += l[i];
      out[i] += l[i];
    } else {
      dinic.addEdge(s, i, u[i] - l[i]);
      in[i] += l[i];
      out[s] += l[i];
    }
  }
  for (int i = 0; i < id + 2; i++) {
    dinic.addEdge(dinic.s, i, in[i]);
    dinic.addEdge(i, dinic.t, out[i]);
  }
  dinic.addEdge(t, s, 1e18);
  if (dinic.maxFlow() < accumulate(in.begin(), in.end(), 0LL)) {
    cout << "-1\n";
    return 0;
  }
  dinic.s = s;
  dinic.t = t;
  long long ret = dinic.maxFlow();
  cout << ret * min(r, b) + (n - ret) * max(r, b) << "\n";
  for (int i = 0; i < n; i++) {
    if (dinic.edges[2 * i].flow ^ (r > b))
      cout << 'r';
    else
      cout << 'b';
  }
  return 0;
}