#include <bits/stdc++.h>
using namespace std;
int n, m, r, b, w[100001], h[100001], sw[100001], sh[100001], s, t, S, T, ns,
    nt, last[100001 * 2], dis[100001 * 2], cur[100001 * 2], cnt, num[100001],
    mn[100001 * 2], mx[100001 * 2];
long long deg[100001 * 2];
struct edge {
  int to, next;
  long long c;
} e[100001 * 30];
struct data {
  int x, y;
} a[100001];
void addedge(int u, int v, long long c) {
  e[++cnt].to = v;
  e[cnt].c = c;
  e[cnt].next = last[u];
  last[u] = cnt;
  e[++cnt].to = u;
  e[cnt].c = 0;
  e[cnt].next = last[v];
  last[v] = cnt;
}
bool bfs() {
  queue<int> q;
  for (int i = s; i <= T; i++) dis[i] = 0;
  dis[ns] = 1;
  q.push(ns);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = last[u]; i; i = e[i].next)
      if (e[i].c && !dis[e[i].to]) {
        dis[e[i].to] = dis[u] + 1;
        if (e[i].to == nt) return true;
        q.push(e[i].to);
      }
  }
  return false;
}
long long dfs(int x, long long maxf) {
  if (x == nt || !maxf) return maxf;
  int ret = 0;
  for (int &i = cur[x]; i; i = e[i].next)
    if (e[i].c && dis[e[i].to] == dis[x] + 1) {
      long long f = dfs(e[i].to, min(e[i].c, maxf - ret));
      e[i].c -= f;
      e[i ^ 1].c += f;
      ret += f;
      if (maxf == ret) break;
    }
  return ret;
}
long long dinic() {
  long long ans = 0;
  while (bfs()) {
    for (int i = s; i <= T; i++) cur[i] = last[i];
    ans += dfs(ns, 1e15);
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  cnt = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    w[i] = a[i].x;
    h[i] = a[i].y;
  }
  sort(w + 1, w + n + 1);
  int w1 = unique(w + 1, w + n + 1) - w - 1;
  sort(h + 1, h + n + 1);
  int h1 = unique(h + 1, h + n + 1) - h - 1;
  s = 0;
  t = w1 + h1 + 1;
  for (int i = 1; i <= n; i++) {
    int x = lower_bound(w + 1, w + w1 + 1, a[i].x) - w;
    int y = lower_bound(h + 1, h + h1 + 1, a[i].y) - h;
    sw[x]++;
    sh[y]++;
    addedge(x, y + w1, 1);
    num[i] = cnt;
  }
  for (int i = 1; i <= w1 + h1; i++) {
    mn[i] = n;
    mx[i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int ty, l, d;
    scanf("%d%d%d", &ty, &l, &d);
    if (ty == 1) {
      int p = lower_bound(w + 1, w + w1 + 1, l) - w;
      if (w[p] != l || d >= sw[p]) continue;
      int l1 = (sw[p] - d + 1) / 2, l2 = sw[p] - l1;
      if (l1 > l2) {
        puts("-1");
        return 0;
      }
      mx[p] = max(mx[p], l1);
      mn[p] = min(mn[p], l2);
    } else {
      int p = lower_bound(h + 1, h + h1 + 1, l) - h;
      if (h[p] != l || d >= sh[p]) continue;
      int l1 = (sh[p] - d + 1) / 2, l2 = sh[p] - l1;
      if (l1 > l2) {
        puts("-1");
        return 0;
      }
      mx[p + w1] = max(mx[p + w1], l1);
      mn[p + w1] = min(mn[p + w1], l2);
    }
  }
  for (int i = 1; i <= w1; i++) {
    deg[s] -= mx[i];
    deg[i] += mx[i];
    addedge(s, i, min(sw[i], mn[i]) - mx[i]);
  }
  for (int i = w1 + 1; i <= w1 + h1; i++) {
    deg[t] += mx[i];
    deg[i] -= mx[i];
    addedge(i, t, min(sh[i - w1], mn[i]) - mx[i]);
  }
  int tcnt = cnt;
  S = t + 1;
  T = t + 2;
  addedge(t, s, 1e15);
  long long sum = 0;
  for (int i = s; i <= t; i++)
    if (deg[i] < 0)
      addedge(i, T, -deg[i]);
    else if (deg[i] > 0)
      addedge(S, i, deg[i]), sum += deg[i];
  ns = S;
  nt = T;
  if (dinic() != sum) {
    puts("-1");
    return 0;
  }
  for (int i = tcnt + 1; i <= cnt; i++) e[i].c = 0;
  ns = s;
  nt = t;
  dinic();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (e[num[i]].c)
      ans += min(b, r);
    else
      ans += max(b, r);
  }
  printf("%I64d\n", ans);
  for (int i = 1; i <= n; i++)
    if (e[num[i]].c)
      putchar(r > b ? 'b' : 'r');
    else
      putchar(r > b ? 'r' : 'b');
}
