#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int NN = 1e5 + 10, N = 2e5 + 10, M = 10 * NN, Z = 1e9 + 7,
          ms63 = 0x3f3f3f3f;
int n, m;
long long r, b;
int x[NN], y[NN];
int ox[NN], oy[NN];
int limx[NN], limy[NN];
int numx[NN], numy[NN];
int ST, ED;
int first[N];
int id;
int w[M], cap[M], nxt[M];
void ins(int x, int y, int cap_) {
  w[++id] = y;
  cap[id] = cap_;
  nxt[id] = first[x];
  first[x] = id;
  w[++id] = x;
  cap[id] = 0;
  nxt[id] = first[y];
  first[y] = id;
}
int d[N];
bool bfs() {
  memset(d, -1, sizeof(d));
  queue<int> q;
  q.push(ST);
  d[ST] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int z = first[x]; z; z = nxt[z])
      if (cap[z]) {
        int y = w[z];
        if (d[y] == -1) {
          d[y] = d[x] + 1;
          q.push(y);
          if (y == ED) return 1;
        }
      }
  }
  return 0;
}
int dfs(int x, int all) {
  if (x == ED) return all;
  int use = 0;
  for (int z = first[x]; z; z = nxt[z])
    if (cap[z]) {
      int y = w[z];
      if (d[y] == d[x] + 1) {
        int tmp = dfs(y, min(cap[z], all - use));
        cap[z] -= tmp;
        cap[z ^ 1] += tmp;
        use += tmp;
        if (use == all) break;
      }
    }
  if (use == 0) d[x] = -1;
  return use;
}
int dinic() {
  int ret = 0;
  while (bfs()) ret += dfs(ST, ms63);
  return ret;
}
int IN[N], bot[N], top[N];
char anss[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(first, 0, sizeof(first));
    id = 1;
    scanf("%lld%lld", &r, &b);
    bool swp = 0;
    if (r > b) swap(r, b), swp = 1;
    for (int i = 1; i <= n; ++i) {
      scanf("%d%d", &x[i], &y[i]);
      ox[i] = x[i];
      oy[i] = y[i];
    }
    sort(ox + 1, ox + n + 1);
    int gx = unique(ox + 1, ox + n + 1) - ox - 1;
    for (int i = 1; i <= gx; ++i) limx[i] = 1e9, numx[i] = 0;
    sort(oy + 1, oy + n + 1);
    int gy = unique(oy + 1, oy + n + 1) - oy - 1;
    for (int i = 1; i <= gy; ++i) limy[i] = 1e9, numy[i] = 0;
    for (int i = 1; i <= n; ++i) {
      x[i] = lower_bound(ox + 1, ox + gx + 1, x[i]) - ox;
      y[i] = lower_bound(oy + 1, oy + gy + 1, y[i]) - oy;
      ++numx[x[i]];
      ++numy[y[i]];
      ins(x[i], gx + y[i], 1);
    }
    ST = 0;
    ED = gx + gy + 3;
    int ST_ = gx + gy + 1;
    int ED_ = gx + gy + 2;
    for (int i = 1; i <= m; ++i) {
      int op, p, lim;
      scanf("%d%d%d", &op, &p, &lim);
      if (op == 1) {
        int pp = lower_bound(ox + 1, ox + gx + 1, p) - ox;
        if (pp <= gx && ox[pp] == p) gmin(limx[pp], lim);
      } else {
        int pp = lower_bound(oy + 1, oy + gy + 1, p) - oy;
        if (pp <= gy && oy[pp] == p) gmin(limy[pp], lim);
      }
    }
    bool ok = 1;
    memset(IN, 0, sizeof(IN));
    for (int i = 1; i <= gx; ++i) {
      bot[i] = max(0, (numx[i] - limx[i] + 1) / 2);
      top[i] = (numx[i] + limx[i]) / 2;
      if (top[i] < bot[i]) {
        ok = 0;
        break;
      }
      ins(ST_, i, top[i] - bot[i]);
      IN[ST_] -= bot[i];
      IN[i] += bot[i];
    }
    for (int i = 1; i <= gy; ++i) {
      bot[gx + i] = max(0, (numy[i] - limy[i] + 1) / 2);
      top[gx + i] = (numy[i] + limy[i]) / 2;
      if (top[gx + i] < bot[gx + i]) {
        ok = 0;
        break;
      }
      ins(gx + i, ED_, top[gx + i] - bot[gx + i]);
      IN[gx + i] -= bot[gx + i];
      IN[ED_] += bot[gx + i];
    }
    if (!ok) {
      puts("-1");
      continue;
    }
    int sum = 0;
    for (int i = 1; i <= gx + gy + 2; ++i) {
      if (IN[i] > 0) ins(ST, i, IN[i]), sum += IN[i];
      if (IN[i] < 0) ins(i, ED, -IN[i]);
    }
    ins(ED_, ST_, 1e9);
    int flow = dinic();
    if (flow != sum) {
      puts("-1");
      continue;
    }
    ST = ST_;
    ED = ED_;
    dinic();
    int rnum = 0;
    for (int i = 1; i <= n; ++i) {
      rnum += cap[i << 1 | 1] > 0;
      anss[i] = (swp ^ (cap[i << 1 | 1] > 0)) ? 'r' : 'b';
    }
    long long ans = rnum * r + (n - rnum) * b;
    printf("%lld\n", ans);
    anss[n + 1] = 0;
    puts(anss + 1);
  }
  return 0;
}
