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;
namespace fastIO1 {
inline char read() {
  static const int IN_LEN = 1000000;
  static char buf[IN_LEN], *s, *t;
  return (s == t               ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin),
          (s == t ? -1 : *s++) : *s++);
}
template <class T>
inline void read(T &x) {
  static bool iosig;
  static char c;
  for (iosig = false, c = read(); !isdigit(c); c = read()) {
    if (c == '-') iosig = true;
    if (c == -1) return;
  }
  for (x = 0; isdigit(c); c = read()) x = ((x + (x << 2)) << 1) + (c ^ '0');
  if (iosig) x = -x;
}
inline char readc(char &c) {
  for (c = read(); !isalpha(c) && !isdigit(c); c = read())
    if (c == -1) return 0;
}
const int OUT_LEN = 10000000;
char obuf[OUT_LEN], *ooh = obuf;
inline void print(char c) {
  if (ooh == obuf + OUT_LEN) fwrite(obuf, 1, OUT_LEN, stdout), ooh = obuf;
  *ooh++ = c;
}
template <class T>
inline void print(T x) {
  static int buf[30], cnt;
  if (x == 0)
    print('0');
  else {
    if (x < 0) print('-'), x = -x;
    for (cnt = 0; x; x /= 10) buf[++cnt] = x % 10 + 48;
    while (cnt) print((char)buf[cnt--]);
  }
}
inline void flush() { fwrite(obuf, 1, ooh - obuf, stdout); }
}  // namespace fastIO1
namespace fastIO2 {
template <class T>
inline void read(T &x) {
  static bool iosig;
  static char c;
  for (iosig = false, c = getchar(); !isdigit(c); c = getchar()) {
    if (c == '-') iosig = true;
    if (c == -1) return;
  }
  for (x = 0; isdigit(c); c = getchar()) x = ((x + (x << 2)) << 1) + (c ^ '0');
  if (iosig) x = -x;
}
}  // namespace fastIO2
using namespace fastIO1;
struct Point {
  long long x, y;
} po[(400010)];
long long n, m, cr, cb, lx[(400010)], ly[(400010)], cnt, cntx, cnty;
long long S, T, S1, T1, V, E = 1, deg[(400010)], lim[(400010)], ans,
                           ot[(400010)];
long long fi[(2000010)], ne[(2000010)], b[(2000010)], c[(2000010)],
    id[(2000010)], d[(400010)], vh[(400010)];
bool ban[(400010)];
void add(long long x, long long y, long long w) {
  ne[++E] = fi[x], fi[x] = E, b[E] = y, c[E] = w;
  ne[++E] = fi[y], fi[y] = E, b[E] = x, c[E] = 0;
  deg[x]++, deg[y]++;
}
void dist() {
  memset(d, 0, sizeof(d));
  queue<long long> Q;
  Q.push(T), d[T] = 0;
  while (!Q.empty()) {
    long long u = Q.front();
    Q.pop();
    for (long long i = fi[u]; i; i = ne[i]) {
      long long v = b[i];
      if (d[v] || v == T) continue;
      d[v] = d[u] + 1, Q.push(v);
    }
  }
}
long long dfs(long long u, long long Flow) {
  if (u == T || Flow == 0) return Flow;
  long long res = Flow, mindist = V - 1;
  for (long long i = fi[u]; i; i = ne[i])
    if (c[i] && !ban[b[i]]) {
      long long v = b[i], nega = i ^ 1;
      if (d[u] == d[v] + 1) {
        long long x = dfs(v, min(res, c[i]));
        res -= x, c[i] -= x, c[nega] += x;
        if (d[S] == V) return Flow - res;
        if (!res) break;
      }
      mindist = min(d[v], mindist);
    }
  if (Flow == res) {
    vh[d[u]]--;
    if (!vh[d[u]])
      d[S] = V;
    else
      d[u] = mindist + 1, vh[d[u]]++;
  }
  return Flow - res;
}
void ISAP(long long st, long long en) {
  memset(vh, 0, sizeof(vh));
  S = st, T = en, dist();
  for (long long i = 1; i <= V; i++) vh[d[i]]++;
  while (d[S] < V) {
    long long kk = dfs(S, (0x7f7f7f7f));
    ans += kk;
  }
  S -= 2, T -= 2, V -= 2;
}
bool check() {
  for (long long i = fi[S1]; i; i = ne[i])
    if (c[i]) return 0;
  return 1;
}
signed main() {
  read(n), read(m), read(cr), read(cb);
  for (long long i = 1; i <= n; i++)
    read(po[i].x), read(po[i].y), lx[i] = po[i].x;
  sort(lx + 1, lx + n + 1), cnt = unique(lx + 1, lx + n + 1) - lx - 1,
                            cntx = cnt;
  for (long long i = 1; i <= n; i++)
    po[i].x = lower_bound(lx + 1, lx + cnt + 1, po[i].x) - lx;
  for (long long i = 1; i <= n; i++) ly[i] = po[i].y;
  sort(ly + 1, ly + n + 1), cnt = unique(ly + 1, ly + n + 1) - ly - 1,
                            cnty = cnt;
  for (long long i = 1; i <= n; i++)
    po[i].y = lower_bound(ly + 1, ly + cnt + 1, po[i].y) - ly;
  S = cntx + cnty + 1, T = S + 1, S1 = T + 1, T1 = T + 2, V = T1;
  for (long long i = 1; i <= n; i++)
    add(po[i].x, cntx + po[i].y, 1), id[E - 1] = i;
  memset(lim, (0x7f7f7f7f), sizeof(lim));
  for (long long i = 1; i <= m; i++) {
    long long op, x, d;
    read(op), read(x), read(d);
    long long pos;
    if (op == 1)
      pos = lower_bound(lx + 1, lx + cntx + 1, x) - lx;
    else
      pos = lower_bound(ly + 1, ly + cnty + 1, x) - ly;
    if (op == 1 && lx[pos] != x) continue;
    if (op == 2 && ly[pos] != x) continue;
    if (op == 2) pos += cntx;
    lim[pos] = min(lim[pos], d);
  }
  for (long long i = 1; i < S; i++) {
    lim[i] = min(lim[i], deg[i]);
    long long L = (deg[i] - lim[i] + 1) / 2, R = (deg[i] + lim[i]) / 2;
    if (L > R) puts("-1"), exit(0);
    if (i <= cntx)
      add(S1, i, L), add(S, T1, L), add(S, i, R - L);
    else
      add(S1, T, L), add(i, T1, L), add(i, T, R - L);
  }
  add(T, S, (0x7f7f7f7f)), ISAP(S1, T1);
  if (!check()) puts("-1"), exit(0);
  ans = c[fi[S]];
  fi[S] = ne[fi[S]], fi[T] = ne[fi[T]], ban[S1] = ban[T1] = 1;
  ISAP(S, T);
  long long fl = 0;
  if (cr > cb) swap(cr, cb), fl = 1;
  cout << (1ll * ans * cr + 1ll * (n - ans) * cb) << endl;
  for (long long i = 1; i <= cntx; i++) {
    for (long long j = fi[i]; j; j = ne[j]) {
      if (!id[j]) continue;
      if (!c[j])
        ot[id[j]] = fl;
      else
        ot[id[j]] = fl ^ 1;
    }
  }
  for (long long i = 1; i <= n; i++)
    if (ot[i] == 0)
      putchar('r');
    else
      putchar('b');
}