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>
const int N = 200005, inf = 0x3f3f3f3f;
std::map<int, std::tuple<int, int, int>> h, v;
int n, m, r, b, idx, d[N], head[N], tot = 1, first[N];
int s, t, S, T, x[N], y[N], id[N * 10];
bool f;
struct edge {
  int to, nxt, rem;
} e[N * 10];
void link(int x, int y, int z) {
  e[++tot] = (edge){y, head[x], z}, head[x] = tot;
  e[++tot] = (edge){x, head[y], 0}, head[y] = tot;
}
void link(int x, int y, int l, int r) {
  link(x, y, r - l), d[x] += l, d[y] -= l;
}
void no() { std::cout << "-1\n", std::exit(0); }
int dis[N];
bool bfs(int s, int t) {
  std::memset(dis, 0, T + 1 << 2);
  std::queue<int> q;
  q.push(s), dis[s] = 1;
  while (q.size()) {
    int tmp = q.front();
    q.pop();
    for (int i = head[tmp]; i; i = e[i].nxt)
      if (e[i].rem && !dis[e[i].to])
        dis[e[i].to] = dis[tmp] + 1, q.push(e[i].to);
  }
  return dis[t] > 0;
}
int dinic(int x, int target, int low) {
  if (!low || x == target) return low;
  int ans = 0;
  for (int &i = first[x], t; i; i = e[i].nxt)
    if (e[i].rem && dis[e[i].to] == dis[x] + 1 &&
        (t = dinic(e[i].to, target, std::min(e[i].rem, low)))) {
      e[i].rem -= t, e[i ^ 1].rem += t, low -= t, ans += t;
      if (!low) break;
    }
  return ans;
}
std::string ans;
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m >> r >> b, s = 0, ans.resize(n);
  if (r > b) std::swap(r, b), f = 1;
  for (int i = 0; i < n; ++i)
    std::cin >> x[i] >> y[i], ++std::get<0>(h[x[i]]), ++std::get<0>(v[y[i]]);
  for (auto &t : h) std::get<1>(t.second) = ++idx, std::get<2>(t.second) = inf;
  int mid = idx;
  for (auto &t : v) std::get<1>(t.second) = ++idx, std::get<2>(t.second) = inf;
  s = ++idx, t = ++idx, S = ++idx, T = ++idx;
  for (int i = 0; i < n; ++i)
    link(std::get<1>(h[x[i]]), std::get<1>(v[y[i]]), 1), id[tot - 1] = i;
  for (int i = 0; i < m; ++i) {
    int t, l, d;
    std::cin >> t >> l >> d;
    auto &m = t == 1 ? h : v;
    if (!m.count(l)) continue;
    int &v = std::get<2>(m[l]);
    v = std::min(v, d);
  }
  for (auto p : h) {
    auto y = p.second;
    int l = std::max(std::get<0>(y) - std::get<2>(y) + 1 >> 1, 0),
        r = std::min(std::get<0>(y) + std::get<2>(y) >> 1, std::get<0>(y));
    if (l > r) no();
    link(s, std::get<1>(y), l, r);
  }
  for (auto p : v) {
    auto y = p.second;
    int l = std::max(std::get<0>(y) - std::get<2>(y) + 1 >> 1, 0),
        r = std::min(std::get<0>(y) + std::get<2>(y) >> 1, std::get<0>(y));
    if (l > r) no();
    link(std::get<1>(y), t, l, r);
  }
  int tmp = tot;
  link(t, s, inf);
  for (int i = 1; i <= t; ++i)
    if (d[i] > 0)
      link(i, T, d[i]);
    else
      link(S, i, -d[i]);
  while (bfs(S, T)) {
    std::memcpy(first, head, T + 1 << 2);
    dinic(S, T, inf);
  }
  for (int i = head[S]; i; i = e[i].nxt)
    if (e[i].rem) no();
  for (int i = 1; i <= T; ++i)
    for (int j = head[i]; j; j = e[j].nxt)
      if (i == S || i == T || e[j].to == S || e[j].to == T) e[j].rem = 0;
  e[tmp + 1].rem = e[tmp + 2].rem = 0;
  while (bfs(s, t)) {
    std::memcpy(first, head, T + 1 << 2);
    dinic(s, t, inf);
  }
  for (int i = 1; i <= mid; ++i)
    for (int j = head[i]; j; j = e[j].nxt)
      if (e[j].to < s && e[j].to > mid) ans[id[j]] = e[j].rem ^ f ? 'b' : 'r';
  int R = std::count(ans.begin(), ans.end(), f ? 'b' : 'r'), B = n - R;
  std::cout << (long long)R * r + (long long)B * b << '\n' << ans << '\n';
  return 0;
}