#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (c < 48) c == '-' && (f = -1), c = getchar();
  while (c > 47) x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;
int h[MAXN], deg[MAXN], d[MAXN], eid[MAXN];
int mi[MAXN], cnt[MAXN], xy[MAXN];
int n, m, st, ed, vs, vt, tot, rc, bc, idn, en = 1;
map<int, int> numx, numy;
bool changeflag;
struct edge {
  int n, v, w;
} e[MAXN << 3];
void add(int x, int y, int z) {
  e[++en] = (edge){h[x], y, z};
  h[x] = en;
}
void exadd(int x, int y, int z) { add(x, y, z), add(y, x, 0); }
void lradd(int x, int y, int l, int r) {
  deg[y] += l;
  deg[x] -= l;
  exadd(x, y, r - l);
}
bool bfs(int st, int aim) {
  memset(d, 0, sizeof d);
  queue<int> q;
  q.push(st);
  d[st] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = h[x]; i; i = e[i].n) {
      int y = e[i].v;
      if (!d[y] && e[i].w) {
        d[y] = d[x] + 1;
        if (y == aim) return 1;
        q.push(y);
      }
    }
  }
  return 0;
}
int dfs(int x, int flow, int aim) {
  if (x == aim) return flow;
  int rest = flow;
  for (int i = h[x]; i && rest; i = e[i].n) {
    int y = e[i].v;
    if (d[y] == d[x] + 1 && e[i].w) {
      int tp = dfs(y, min(rest, e[i].w), aim);
      if (!tp) d[y] = 0;
      rest -= tp;
      e[i].w -= tp;
      e[i ^ 1].w += tp;
    }
  }
  return flow - rest;
}
int dinic(int st, int ed) {
  int res = 0;
  while (bfs(st, ed)) res += dfs(st, INT_MAX, ed);
  return res;
}
signed main() {
  n = read();
  m = read();
  rc = read();
  bc = read();
  if (rc > bc) swap(rc, bc), changeflag = 1;
  for (int i = 1, x, y; i <= n; i++) {
    x = read();
    y = read();
    if (!numx[x]) numx[x] = ++idn, mi[idn] = INT_MAX;
    cnt[numx[x]]++;
    if (!numy[y]) numy[y] = ++idn, mi[idn] = INT_MAX, xy[idn] = 1;
    cnt[numy[y]]++;
    exadd(numx[x], numy[y], 1);
    eid[i] = en;
  }
  while (m--) {
    int op = read(), x = read(), v = read();
    if (op == 1) {
      x = numx[x];
      if (!x) continue;
      mi[x] = min(mi[x], v);
    } else {
      x = numy[x];
      if (!x) continue;
      mi[x] = min(mi[x], v);
    }
  }
  st = idn + 1;
  ed = st + 1;
  vs = 0;
  vt = ed + 1;
  for (int i = 1; i <= idn; i++) {
    int c = cnt[i], d = min(mi[i], c), l = c - d + 1 >> 1, r = c + d >> 1;
    if (l > r) return puts("-1"), 0;
    if (!xy[i])
      lradd(st, i, l, r);
    else
      lradd(i, ed, l, r);
  }
  for (int i = vs + 1; i <= vt - 1; i++) {
    if (deg[i] < 0) exadd(i, vt, -deg[i]);
    if (deg[i] > 0) exadd(vs, i, deg[i]), tot += deg[i];
  }
  exadd(ed, st, INT_MAX);
  if (dinic(vs, vt) ^ tot) return puts("-1"), 0;
  int ans = dinic(st, ed);
  printf("%lld\n", 1ll * ans * rc + 1ll * (n - ans) * bc);
  for (int i = 1; i <= n; i++) {
    if (e[eid[i]].w ^ changeflag)
      putchar('r');
    else
      putchar('b');
  }
}
