#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
}
using namespace std;
const long long inf = 1e9 + 1000000;
inline void MIN(long long &a, long long b) {
  if (b < a) a = b;
}
inline void MAX(long long &a, long long b) {
  if (b > a) a = b;
}
long long n, m, R, B, s, t, S, T;
long long X[201000], Y[201000], hx[201000], hy[201000], xtot, ytot;
vector<long long> r[201000], c[201000];
long long mnjuer[201000], mnjuec[201000];
struct edge {
  long long nxt, to, val;
  edge() {}
  edge(long long jzp, long long zzz, long long lsr) {
    nxt = jzp, to = zzz, val = lsr;
  }
} e[2001000];
long long head[201000], ecnt = 1, hcur[201000];
inline void addedge(long long from, long long to, long long val) {
  e[++ecnt] = edge(head[from], to, val);
  head[from] = ecnt;
}
inline void Addedge(long long u, long long v, long long w) {
  addedge(u, v, w), addedge(v, u, 0);
}
long long dep[201000], que[201000], front, rear;
inline bool bfs(long long s, long long t) {
  memset(dep, 0x3f, sizeof(dep));
  front = rear = 0;
  for (long long i = 1; i <= T; ++i) hcur[i] = head[i];
  dep[s] = 0;
  que[++rear] = s;
  while (front < rear) {
    long long cur = que[++front];
    for (long long i = head[cur]; i; i = e[i].nxt) {
      long long to = e[i].to;
      if (!e[i].val || dep[to] < inf) continue;
      dep[to] = dep[cur] + 1;
      que[++rear] = to;
    }
  }
  return dep[t] < inf;
}
long long dfs(long long cur, long long limi, long long t) {
  if (cur == t || !limi) return limi;
  long long flow = 0;
  for (long long i = hcur[cur]; i; i = e[i].nxt) {
    long long to = e[i].to;
    hcur[cur] = i;
    if (dep[to] != dep[cur] + 1) continue;
    long long tmp = dfs(to, min(e[i].val, limi), t);
    if (!tmp) continue;
    e[i].val -= tmp;
    e[i ^ 1].val += tmp;
    flow += tmp;
    limi -= tmp;
    if (!limi) break;
  }
  return flow;
}
long long eid[201000], in[201000], out[201000];
char chr[201000];
signed main() {
  read(n), read(m);
  read(R), read(B);
  char ch[2] = {'r', 'b'};
  if (R < B) swap(R, B), swap(ch[0], ch[1]);
  long long ans = 1ll * R * n;
  for (long long i = 1; i <= n; ++i) {
    read(X[i]), read(Y[i]);
    hx[++xtot] = X[i];
    hy[++ytot] = Y[i];
  }
  sort(hx + 1, hx + 1 + n);
  xtot = unique(hx + 1, hx + 1 + n) - hx - 1;
  sort(hy + 1, hy + 1 + n);
  ytot = unique(hy + 1, hy + 1 + n) - hy - 1;
  for (long long i = 1; i <= n; ++i) {
    X[i] = lower_bound(hx + 1, hx + 1 + xtot, X[i]) - hx;
    Y[i] = lower_bound(hy + 1, hy + 1 + ytot, Y[i]) - hy;
    r[X[i]].push_back(i);
    c[Y[i]].push_back(i);
  }
  memset(mnjuer, 0x3f, sizeof(mnjuer));
  memset(mnjuec, 0x3f, sizeof(mnjuec));
  for (long long i = 1; i <= m; ++i) {
    long long t, l, d;
    read(t), read(l), read(d);
    if (t == 1) {
      long long jzp = lower_bound(hx + 1, hx + 1 + xtot, l) - hx;
      if (hx[jzp] == l) MIN(mnjuer[jzp], d);
    } else {
      long long jzp = lower_bound(hy + 1, hy + 1 + ytot, l) - hy;
      if (hy[jzp] == l) MIN(mnjuec[jzp], d);
    }
  }
  s = xtot + ytot + 1, t = s + 1;
  S = t + 1, T = S + 1;
  for (long long i = 1; i <= xtot; ++i) {
    long long sz = r[i].size(), l = mnjuer[i];
    if (l >= sz) {
      Addedge(s, i, inf);
    } else {
      long long d = (sz - l + 1) >> 1, u = (sz + l) >> 1;
      if (d > u) {
        puts("-1");
        return 0;
      }
      Addedge(s, i, u - d);
      out[s] += d;
      in[i] += d;
    }
  }
  for (long long i = 1; i <= ytot; ++i) {
    long long sz = c[i].size(), l = mnjuec[i];
    if (l > inf) {
      Addedge(xtot + i, t, inf);
    } else {
      long long d = (sz - l + 1) >> 1, u = (sz + l) >> 1;
      if (d > u) {
        puts("-1");
        return 0;
      }
      Addedge(xtot + i, t, u - d);
      out[xtot + i] += d;
      in[t] += d;
    }
  }
  for (long long i = 1; i <= n; ++i)
    Addedge(X[i], xtot + Y[i], 1), eid[i] = ecnt ^ 1;
  Addedge(t, s, inf);
  long long memoe = ecnt;
  long long jzp = 0;
  for (long long i = 1; i <= t; ++i)
    if (in[i] > out[i])
      Addedge(S, i, in[i] - out[i]), jzp += in[i] - out[i];
    else
      Addedge(i, T, out[i] - in[i]);
  long long mxflow = 0;
  while (bfs(S, T)) mxflow += dfs(S, inf, T);
  if (mxflow != jzp) {
    puts("-1");
    return 0;
  }
  e[memoe].val = e[memoe ^ 1].val = 0;
  for (long long i = head[S]; i; i = e[i].nxt) e[i].val = e[i ^ 1].val = 0;
  for (long long i = head[T]; i; i = e[i].nxt) e[i].val = e[i ^ 1].val = 0;
  while (bfs(s, t)) mxflow += dfs(s, inf, t);
  for (long long i = 1; i <= n; ++i)
    if (e[eid[i]].val)
      chr[i] = ch[0];
    else
      chr[i] = ch[1], ans -= R - B;
  printf("%lld\n", ans);
  puts(chr + 1);
  return 0;
}
