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 = 3e5 + 10, M = N * 20, inf = 0x3f3f3f3f;
int tot = 1, to[M], head[N], nxt[M];
long long w[M], de[N];
void add(int x, int y, long long l, long long r) {
  to[++tot] = y, w[tot] = r - l, nxt[tot] = head[x], head[x] = tot;
  to[++tot] = x, w[tot] = 0, nxt[tot] = head[y], head[y] = tot;
  de[y] += l, de[x] -= l;
}
void add2(int x, int y, long long z) {
  to[++tot] = y, w[tot] = z, nxt[tot] = head[x], head[x] = tot;
  to[++tot] = x, w[tot] = 0, nxt[tot] = head[y], head[y] = tot;
}
int dep[N];
bool bfs(int s, int t) {
  memset(dep, 0, sizeof dep);
  dep[s] = 1;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = nxt[i]) {
      if (dep[to[i]] || !w[i]) continue;
      dep[to[i]] = dep[x] + 1;
      q.push(to[i]);
      if (to[i] == t) return true;
    }
  }
  return false;
}
long long dinic(int x, int t, long long lim) {
  if (x == t) return lim;
  long long c = lim;
  for (int i = head[x]; i && c; i = nxt[i]) {
    if (dep[to[i]] != dep[x] + 1 || !w[i]) continue;
    long long f = dinic(to[i], t, min(c, w[i]));
    if (!f) dep[to[i]] = 0;
    c -= f;
    w[i] -= f;
    w[i ^ 1] += f;
  }
  return lim - c;
}
long long run(int s, int t, bool fg) {
  long long flow = 0, mxflow = 0;
  while (bfs(s, t))
    while (flow = dinic(s, t, inf)) mxflow += flow;
  if (fg == 0) {
    for (int i = head[s]; i; i = nxt[i])
      if (w[i]) return -1;
  }
  return mxflow;
}
int n, m, r, b, num[2], x[N], y[N], ty[N], l[N], d[N], ll[N], dd[N], ee[M];
int s, t, S, T;
char ch[2];
long long ans;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  cin >> r >> b;
  ch[0] = 'r', ch[1] = 'b';
  if (r < b) swap(r, b), swap(ch[0], ch[1]);
  ans = 1ll * r * n;
  vector<int> g[2];
  for (int i = 1; i <= n; ++i)
    cin >> x[i] >> y[i], g[0].push_back(x[i]), g[1].push_back(y[i]);
  for (int i = 1; i <= m; ++i)
    cin >> ty[i] >> l[i] >> d[i], g[--ty[i]].push_back(l[i]);
  for (int i = 0; i < 2; ++i)
    sort(g[i].begin(), g[i].end()),
        g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end()),
        num[i] = g[i].size();
  s = 0, t = num[0] + num[1] + 1;
  S = t + 1, T = t + 2;
  for (int i = 1; i <= n; ++i) {
    x[i] = lower_bound(g[0].begin(), g[0].end(), x[i]) - g[0].begin() + 1,
    y[i] = lower_bound(g[1].begin(), g[1].end(), y[i]) - g[1].begin() + 1;
    add2(x[i], num[0] + y[i], 1);
    ee[i] = tot;
    ++ll[x[i]], ++ll[num[0] + y[i]];
  }
  for (int i = 1; i <= num[0] + num[1]; ++i) dd[i] = ll[i];
  for (int i = 1; i <= m; ++i) {
    l[i] = lower_bound(g[ty[i]].begin(), g[ty[i]].end(), l[i]) -
           g[ty[i]].begin() + 1;
    l[i] = l[i] + (ty[i] == 1 ? num[0] : 0);
    dd[l[i]] = min(dd[l[i]], d[i]);
  }
  for (int i = 1; i <= num[0] + num[1]; ++i) {
    int wl = (ll[i] - dd[i] + 1) / 2, wr = (ll[i] + dd[i]) / 2;
    if (wl > wr) cout << -1 << endl, exit(0);
    if (!wr) continue;
    if (i <= num[0])
      add(s, i, wl, wr);
    else
      add(i, t, wl, wr);
  }
  add2(t, s, inf);
  for (int i = s; i <= t; ++i)
    if (de[i] > 0)
      add2(S, i, de[i]);
    else if (de[i] < 0)
      add2(i, T, -de[i]);
  if (run(S, T, 0) == -1) cout << -1 << endl, exit(0);
  ans -= 1ll * run(s, t, 1) * (r - b);
  cout << ans << endl;
  for (int i = 1; i <= n; ++i) cout << ch[w[ee[i]]];
  cout << endl;
  return 0;
}