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 = 200100, M = N << 5, inf = 2e9;
int n, m, R, B, ff, c1, c2, S, T, SS, TT, cc, sum, w[N], s1[N], s2[N], m1[N],
    m2[N], hd[N], iter[N], d[N], dis[N];
pair<int, int> a[N], b[N], p[N];
map<int, int> f1, f2;
queue<int> Q;
struct E {
  int v, w, nxt;
} e[M];
inline void add(int u, int v, int w) {
  e[++cc] = (E){v, w, hd[u]};
  hd[u] = cc;
  e[++cc] = (E){u, 0, hd[v]};
  hd[v] = cc;
}
inline void addud(int u, int v, int l, int r) {
  add(u, v, r - l);
  d[u] -= l;
  d[v] += l;
}
inline bool bfs(int s, int t) {
  memcpy(iter, hd, sizeof(hd));
  memset(dis, -1, sizeof(dis));
  Q.push(s);
  dis[s] = 0;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = hd[x], y; i; i = e[i].nxt)
      if (e[i].w && dis[y = e[i].v] == -1) {
        dis[y] = dis[x] + 1;
        Q.push(y);
      }
  }
  return ~dis[t];
}
int dfs(int x, int t, int f) {
  if (x == t || !f) return f;
  int sf = 0, y;
  for (int &i = iter[x]; i; i = e[i].nxt)
    if (e[i].w && dis[y = e[i].v] == dis[x] + 1) {
      int w = dfs(y, t, min(f, e[i].w));
      e[i].w -= w;
      e[i ^ 1].w += w;
      f -= w;
      sf += w;
      if (!f) break;
    }
  return sf;
}
int dinic(int s, int t) {
  int res = 0;
  while (bfs(s, t)) res += dfs(s, t, inf);
  return res;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &R, &B);
  S = N - 1;
  T = N - 2;
  SS = N - 3;
  TT = N - 4;
  cc = 1;
  if (R > B) swap(R, B), ff = 1;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].first, &b[i].first), a[i].second = b[i].second = i;
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i].first ^ a[i - 1].first) f1[a[i].first] = ++c1;
    p[a[i].second].first = c1;
    s1[c1]++;
    if (b[i].first ^ b[i - 1].first) f2[b[i].first] = ++c2;
    p[b[i].second].second = c2;
    s2[c2]++;
  }
  for (int i = 1; i <= c1; i++) m1[i] = s1[i];
  for (int i = 1; i <= c2; i++) m2[i] = s2[i];
  for (int i = 1; i <= n; i++)
    add(p[i].first, p[i].second + c1, 1), w[i] = cc - 1;
  for (int i = 1, t, l, d; i <= m; i++) {
    scanf("%d%d%d", &t, &l, &d);
    if (t & 1) {
      if (!f1.count(l))
        continue;
      else {
        l = f1[l];
        m1[l] = min(m1[l], d);
      }
    } else {
      if (!f2.count(l))
        continue;
      else {
        l = f2[l];
        m2[l] = min(m2[l], d);
      }
    }
  }
  for (int i = 1; i <= c1; i++)
    if (!m1[i] && s1[i] & 1) {
      puts("-1");
      return 0;
    } else
      addud(S, i, (s1[i] - m1[i] + 1) / 2, (s1[i] + m1[i]) / 2);
  for (int i = 1; i <= c2; i++)
    if (!m2[i] && s2[i] & 1) {
      puts("-1");
      return 0;
    } else
      addud(i + c1, T, (s2[i] - m2[i] + 1) / 2, (s2[i] + m2[i]) / 2);
  for (int i = 0; i < N; i++)
    if (d[i] > 0)
      add(SS, i, d[i]), sum += d[i];
    else
      add(i, TT, -d[i]);
  add(T, S, inf);
  int res = dinic(SS, TT);
  if (res ^ sum) {
    puts("-1");
    return 0;
  }
  res = dinic(S, T);
  printf("%lld\n", 1ll * res * R + 1ll * (n - res) * B);
  for (int i = 1; i <= n; i++) putchar((e[w[i]].w ^ ff) ? 'b' : 'r');
  return 0;
}