#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int M = 2100000;
const int INF = 0x3f3f3f3f;
int n, m, r, b;
int S, T, SS, TT, num, tot = 1, ans, sum1;
int a[2][N], cnt[2], X[N], Y[N], sum[2][N];
int head[N << 1], nex[M], to[M], val[M];
int mx[2][N], mn[2][N], du[N << 1];
int d[N << 1], pos[N];
queue<int> Q;
int get(int x, int y) {
  return lower_bound(a[y] + 1, a[y] + 1 + cnt[y], x) - a[y];
}
void add(int x, int y, int z) {
  tot++;
  nex[tot] = head[x];
  head[x] = tot;
  to[tot] = y;
  val[tot] = z;
}
int bfs(int S, int T) {
  memset(d, -1, sizeof(d));
  while (!Q.empty()) Q.pop();
  d[S] = 0;
  Q.push(S);
  while (!Q.empty()) {
    int tmp = Q.front();
    Q.pop();
    for (int i = head[tmp]; i; i = nex[i])
      if (d[to[i]] == -1 && val[i]) {
        d[to[i]] = d[tmp] + 1;
        if (to[i] == T) return 1;
        Q.push(to[i]);
      }
  }
  return 0;
}
int dfs(int x, int mv, int T) {
  if (x == T) return mv;
  int tmp = 0;
  for (int i = head[x]; i; i = nex[i])
    if (d[to[i]] == d[x] + 1 && val[i]) {
      int t = dfs(to[i], min(val[i], mv - tmp), T);
      if (!t) d[to[i]] = -1;
      tmp += t;
      val[i] -= t;
      val[i ^ 1] += t;
      if (tmp == mv) break;
    }
  return tmp;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &X[i], &Y[i]);
    a[0][++cnt[0]] = X[i];
    a[1][++cnt[1]] = Y[i];
  }
  for (int i = 0; i <= 1; i++) {
    sort(a[i] + 1, a[i] + 1 + cnt[i]);
    cnt[i] = unique(a[i] + 1, a[i] + 1 + cnt[i]) - a[i] - 1;
  }
  num = cnt[0] + cnt[1];
  S = ++num;
  T = ++num;
  SS = ++num;
  TT = ++num;
  for (int i = 1; i <= n; i++) {
    X[i] = get(X[i], 0);
    Y[i] = get(Y[i], 1);
    sum[0][X[i]]++;
    sum[1][Y[i]]++;
    add(X[i], Y[i] + cnt[0], 1);
    pos[i] = tot;
    add(Y[i] + cnt[0], X[i], 0);
  }
  for (int i = 0; i <= 1; i++)
    for (int j = 1; j <= cnt[i]; j++) mx[i][j] = sum[i][j];
  int t, l, d;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &t, &l, &d);
    t--;
    int t1 = get(l, t);
    if (a[t][t1] != l) continue;
    mx[t][t1] = min(mx[t][t1], (d + sum[t][t1]) / 2);
    mn[t][t1] = max(mn[t][t1], (sum[t][t1] - d + 1) / 2);
    if (mx[t][t1] < mn[t][t1]) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= cnt[0]; i++) {
    if (mx[0][i] != mn[0][i]) {
      add(S, i, mx[0][i] - mn[0][i]);
      add(i, S, 0);
    }
    du[i] += mn[0][i];
    du[S] -= mn[0][i];
  }
  for (int i = 1; i <= cnt[1]; i++) {
    int t = i + cnt[0];
    if (mx[1][i] != mn[1][i]) {
      add(t, T, mx[1][i] - mn[1][i]);
      add(T, t, 0);
    }
    du[T] += mn[1][i];
    du[t] -= mn[1][i];
  }
  for (int i = 1; i <= T; i++)
    if (du[i]) {
      if (du[i] > 0)
        add(SS, i, du[i]), add(i, SS, 0), sum1 += du[i];
      else
        add(i, TT, -du[i]), add(TT, i, 0);
    }
  add(T, S, INF);
  add(S, T, 0);
  while (bfs(SS, TT)) ans += dfs(SS, INF, TT);
  if (ans != sum1) {
    printf("-1\n");
    return 0;
  }
  ans = 0;
  while (bfs(S, T)) ans += dfs(S, INF, T);
  printf("%I64d\n",
         (long long)ans * min(r, b) + (long long)(n - ans) * max(r, b));
  for (int i = 1; i <= n; i++) {
    if (!val[pos[i]])
      putchar(r < b ? 'r' : 'b');
    else
      putchar(r > b ? 'r' : 'b');
  }
  return 0;
}
