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 <class T>
inline void rread(T& num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
inline int getgcd(int x, int y) {
  if (!x) return y;
  return getgcd(y % x, x);
}
inline long long getlcm(int x, int y) {
  return (long long)x / getgcd(x, y) * y;
}
inline long long getgcd(long long x, long long y) {
  if (!x) return y;
  return getgcd(y % x, x);
}
inline long long getlcm(long long x, long long y) {
  return x / getgcd(x, y) * y;
}
inline int power(int x, int k, int p) {
  int res = 1;
  for (; k; k >>= 1, x = (long long)x * x % p)
    if (k & 1) res = (long long)res * x % p;
  return res;
}
inline long long power(long long x, long long k, long long p) {
  long long res = 1;
  for (; k; k >>= 1, x = x * x % p)
    if (k & 1) res = res * x % p;
  return res;
}
const double pi = acos(-1);
inline void judge() { freopen("input.txt", "r", stdin); }
const int maxn = 5e5 + 5, inf = 1e9;
map<int, int> newx, newy;
int n, m, R, B;
long long ans, need;
int x[maxn], y[maxn], q[maxn], du[maxn];
int totx[maxn], toty[maxn], limx[maxn], limy[maxn], check[maxn];
namespace Maxflow {
const int maxn = 500005, maxm = 5000005, inf = 1e9;
int S, T;
int head[maxn], from[maxm], des[maxm], nxt[maxm], f[maxm], tot;
int cur[maxn], d[maxn], h[maxn], pre[maxn];
inline void init(int _S, int _T) {
  S = _S;
  T = _T;
  memset(head, 0, sizeof head);
  tot = 1;
}
inline int adde(int x, int y, int z) {
  from[++tot] = x;
  des[tot] = y;
  f[tot] = z;
  nxt[tot] = head[x];
  head[x] = tot;
  from[++tot] = y;
  des[tot] = x;
  f[tot] = 0;
  nxt[tot] = head[y];
  head[y] = tot;
  return tot;
}
inline int isap(int n) {
  int maxflow = 0, u = S;
  for (int(i) = (1); (i) <= (n); (i)++) pre[i] = d[i] = 0, cur[i] = head[i];
  h[d[0]] = n;
  while (d[S] < n) {
    if (u == T) {
      int minflow = inf, re = S;
      while (u != S) {
        if (f[pre[u]] < minflow) minflow = f[pre[u]], re = from[pre[u]];
        u = from[pre[u]];
      }
      maxflow += minflow;
      u = T;
      while (u != S) {
        f[pre[u]] -= minflow;
        f[pre[u] ^ 1] += minflow;
        u = from[pre[u]];
      }
      u = re;
    }
    bool flag = 0;
    for (int(p) = cur[(u)]; (p); (p) = nxt[(p)]) {
      if (f[p] && d[des[p]] == d[u] - 1) {
        u = des[p];
        pre[u] = p;
        flag = 1;
        break;
      }
      cur[u] = p;
    }
    if (flag) continue;
    cur[u] = head[u];
    int mind = n - 1;
    for (int(p) = cur[(u)]; (p); (p) = nxt[(p)])
      if (f[p] && d[des[p]] < mind) {
        mind = d[des[p]];
        cur[u] = p;
      }
    h[d[u]]--;
    if (!h[d[u]]) break;
    d[u] = mind + 1;
    h[d[u]]++;
    if (u != S) u = from[pre[u]];
  }
  return maxflow;
}
}  // namespace Maxflow
int main() {
  rread(n);
  rread(m);
  rread(R);
  rread(B);
  for (int(i) = (1); (i) <= (n); (i)++) rread(x[i]), rread(y[i]);
  for (int(i) = (1); (i) <= (n); (i)++) q[i] = x[i];
  sort(q + 1, q + n + 1);
  int cntx = 1;
  newx[q[1]] = 1;
  for (int(i) = (2); (i) <= (n); (i)++)
    if (q[i] != q[i - 1]) newx[q[i]] = ++cntx;
  for (int(i) = (1); (i) <= (n); (i)++) q[i] = y[i];
  sort(q + 1, q + n + 1);
  int cnty = 1;
  newy[q[1]] = 1;
  for (int(i) = (2); (i) <= (n); (i)++)
    if (q[i] != q[i - 1]) newy[q[i]] = ++cnty;
  for (int(i) = (1); (i) <= (n); (i)++)
    x[i] = newx[x[i]], y[i] = newy[y[i]], totx[x[i]]++, toty[y[i]]++;
  for (int(i) = (1); (i) <= (cntx); (i)++) limx[i] = totx[i];
  for (int(i) = (1); (i) <= (cnty); (i)++) limy[i] = toty[i];
  for (int(i) = (1); (i) <= (m); (i)++) {
    int t, l, d;
    rread(t);
    rread(l);
    rread(d);
    if (t == 1) {
      if (!newx.count(l)) continue;
      l = newx[l];
      limx[l] = min(limx[l], d);
    } else {
      if (!newy.count(l)) continue;
      l = newy[l];
      limy[l] = min(limy[l], d);
    }
  }
  int S = cntx + cnty + 1, T = S + 1, SS = T + 1, TT = SS + 1;
  Maxflow::init(SS, TT);
  for (int(i) = (1); (i) <= (cntx); (i)++) {
    int low = (totx[i] - limx[i] + 1) / 2, high = (totx[i] + limx[i]) / 2;
    if (low > high) return puts("-1"), 0;
    Maxflow::adde(S, i, high - low);
    du[S] -= low;
    du[i] += low;
  }
  for (int(i) = (1); (i) <= (cnty); (i)++) {
    int low = (toty[i] - limy[i] + 1) / 2, high = (toty[i] + limy[i]) / 2;
    if (low > high) return puts("-1"), 0;
    Maxflow::adde(i + cntx, T, high - low);
    du[i + cntx] -= low;
    du[T] += low;
  }
  for (int(i) = (1); (i) <= (n); (i)++)
    check[i] = Maxflow::adde(x[i], y[i] + cntx, 1);
  Maxflow::adde(T, S, inf);
  for (int(i) = (1); (i) <= (T); (i)++)
    if (du[i] > 0)
      Maxflow::adde(SS, i, du[i]), need += du[i];
    else
      Maxflow::adde(i, TT, -du[i]);
  if (Maxflow::isap(TT) != need)
    puts("-1");
  else {
    Maxflow::S = S;
    Maxflow::T = T;
    Maxflow::isap(T);
    for (int(i) = (1); (i) <= (n); (i)++)
      if (Maxflow::f[check[i]])
        ans += min(R, B);
      else
        ans += max(R, B);
    cout << ans << endl;
    for (int(i) = (1); (i) <= (n); (i)++)
      if (Maxflow::f[check[i]]) {
        if (R < B)
          putchar('r');
        else
          putchar('b');
      } else {
        if (R < B)
          putchar('b');
        else
          putchar('r');
      }
    puts("");
  }
  return 0;
}