#include <bits/stdc++.h>
const int maxn = 1e5 + 7;
const int maxe = 3e6 + 7;
const long long inf = 1e17;
using namespace std;
long long n, m, R, B, s, t, op, l, d, ns, nt, cnt;
long long x[maxn], y[maxn], sx[maxn], sy[maxn], mn[maxn * 2], mx[maxn * 2],
    num[maxn], deg[maxn * 2];
long long ls[maxn * 2], dis[maxn * 2];
queue<long long> q;
struct edge {
  long long y, w, op, next;
} g[maxe];
struct rec {
  long long x, y;
} a[maxn];
void add(long long x, long long y, long long w) {
  g[++cnt] = (edge){y, w, cnt + 1, ls[x]};
  ls[x] = cnt;
  g[++cnt] = (edge){x, 0, cnt - 1, ls[y]};
  ls[y] = cnt;
}
bool bfs() {
  while (!q.empty()) q.pop();
  for (long long i = 0; i <= nt; i++) dis[i] = inf;
  dis[ns] = 0;
  q.push(ns);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (long long i = ls[x]; i > 0; i = g[i].next) {
      long long y = g[i].y;
      if ((g[i].w) && (dis[y] > dis[x] + 1)) {
        dis[y] = dis[x] + 1;
        if (y == nt) return 1;
        q.push(y);
      }
    }
  }
  return 0;
}
long long dfs(long long x, long long maxf) {
  if ((x == nt) || (maxf == 0)) return maxf;
  long long ret = 0;
  for (long long i = ls[x]; i > 0; i = g[i].next) {
    long long y = g[i].y;
    if ((dis[y] == dis[x] + 1) && (g[i].w)) {
      long long f = dfs(y, min(maxf - ret, g[i].w));
      if (!f) dis[y] = 0;
      ret += f;
      g[i].w -= f;
      g[g[i].op].w += f;
      if (ret == maxf) break;
    }
  }
  return ret;
}
long long dinic() {
  long long flow = 0;
  while (bfs()) flow += dfs(ns, inf);
  return flow;
}
int main() {
  scanf("%I64d%I64d", &n, &m);
  scanf("%I64d%I64d", &R, &B);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &a[i].x, &a[i].y);
    x[i] = a[i].x;
    y[i] = a[i].y;
  }
  sort(x + 1, x + n + 1);
  sort(y + 1, y + n + 1);
  long long size1 = unique(x + 1, x + n + 1) - x - 1,
            size2 = unique(y + 1, y + n + 1) - y - 1;
  s = 0, t = size1 + size2 + 1;
  for (long long i = 1; i <= n; i++) {
    long long xx = lower_bound(x + 1, x + size1 + 1, a[i].x) - x;
    long long yy = lower_bound(y + 1, y + size2 + 1, a[i].y) - y;
    add(xx, yy + size1, 1);
    sx[xx]++, sy[yy]++, num[i] = cnt - 1;
  }
  for (long long i = 1; i <= size1 + size2; i++) mn[i] = 0, mx[i] = n;
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &op, &l, &d);
    if (op == 1) {
      long long p = lower_bound(x + 1, x + size1 + 1, l) - x;
      if ((x[p] != l) || (d >= sx[p])) continue;
      long long L = (sx[p] - d + 1) / 2, R = sx[p] - L;
      if (L > R) {
        printf("-1");
        return 0;
      }
      mx[p] = min(mx[p], R);
      mn[p] = max(mn[p], L);
    } else {
      long long p = lower_bound(y + 1, y + size2 + 1, l) - y;
      if ((y[p] != l) || (d >= sy[p])) continue;
      long long L = (sy[p] - d + 1) / 2, R = sy[p] - L;
      if (L > R) {
        printf("-1");
        return 0;
      }
      mx[p + size1] = min(mx[p + size1], R);
      mn[p + size1] = max(mn[p + size1], L);
    }
  }
  for (long long i = 1; i <= size1; i++) {
    deg[s] -= mn[i];
    deg[i] += mn[i];
    add(s, i, min(sx[i], mx[i]) - mn[i]);
  }
  for (long long i = size1 + 1; i <= size1 + size2; i++) {
    deg[i] -= mn[i];
    deg[t] += mn[i];
    add(i, t, min(sy[i - size1], mx[i]) - mn[i]);
  }
  long long nowcnt = cnt, S = t + 1, T = t + 2;
  add(t, s, inf);
  long long sum = 0;
  for (long long i = s; i <= t; i++) {
    if (deg[i] < 0)
      add(i, T, -deg[i]);
    else if (deg[i] > 0)
      add(S, i, deg[i]), sum += deg[i];
  }
  ns = S, nt = T;
  int x1;
  if ((x1 = dinic()) != sum) {
    printf("-1");
    return 0;
  }
  for (long long i = nowcnt + 1; i <= cnt; i++) g[i].w = 0;
  ns = s, nt = t;
  int x = dinic();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!g[num[i]].w)
      ans += min(B, R);
    else
      ans += max(B, R);
  }
  printf("%I64d\n", ans);
  for (long long i = 1; i <= n; i++) {
    if (!g[num[i]].w) {
      if (B < R)
        printf("b");
      else
        printf("r");
    } else {
      if (B < R)
        printf("r");
      else
        printf("b");
    }
  }
}
