#include <bits/stdc++.h>
using namespace std;
const int N = 200005, E = (3 * N) * 2 + 2 * N;
int audhsdf[E], low[E], cap[E], to[E], ant[E], adj[N], delta[N];
int level[N], fila[N], copy_adj[N], inde;
void add_edge(int a, int b, int l, int u) {
  audhsdf[inde] = 0;
  to[inde] = b;
  low[inde] = l;
  cap[inde] = u;
  ant[inde] = adj[a];
  adj[a] = inde++;
  audhsdf[inde] = 0;
  to[inde] = a;
  low[inde] = 0;
  cap[inde] = 0;
  ant[inde] = adj[b];
  adj[b] = inde++;
}
bool bfs(int source, int sink) {
  memset(level, -1, sizeof level);
  level[source] = 0;
  int front = 0, size = 0, v;
  fila[size++] = source;
  while (front < size) {
    v = fila[front++];
    for (int i = adj[v]; ~i; i = ant[i]) {
      if (cap[i] > audhsdf[i] && level[to[i]] == -1) {
        level[to[i]] = level[v] + 1;
        fila[size++] = to[i];
      }
    }
  }
  return level[sink] != -1;
}
int dfs(int v, int sink, int f) {
  if (v == sink) return f;
  for (int& i = copy_adj[v]; ~i; i = ant[i]) {
    if (cap[i] > audhsdf[i] && level[to[i]] == level[v] + 1) {
      int aux = dfs(to[i], sink, min(f, cap[i] - audhsdf[i]));
      if (aux > 0) {
        audhsdf[i] += aux;
        audhsdf[i ^ 1] -= aux;
        return aux;
      }
    }
  }
  return 0;
}
int dinic(int source, int sink) {
  int ret = 0, audhsdf;
  while (bfs(source, sink)) {
    memcpy(copy_adj, adj, sizeof adj);
    while (audhsdf = dfs(source, sink, 1 << 30)) ret += audhsdf;
  }
  return ret;
}
int max_flow(int source, int sink) {
  memset(delta, 0, sizeof delta);
  for (int i = 0; i < inde; i += 2) {
    delta[to[i]] += low[i];
    delta[to[i ^ 1]] -= low[i];
    cap[i] -= low[i];
  }
  adj[sink + 1] = adj[sink + 2] = -1;
  int sum = 0;
  for (int i = 0; i <= sink; ++i) {
    if (delta[i] > 0) {
      add_edge(sink + 1, i, 0, delta[i]);
      sum += delta[i];
    } else if (delta[i] < 0) {
      add_edge(i, sink + 2, 0, -delta[i]);
    }
  }
  add_edge(sink, source, 0, INT_MAX);
  memset(audhsdf, 0, sizeof audhsdf);
  int f = dinic(sink + 1, sink + 2);
  if (f != sum) return -1;
  for (int i = 0; i < inde; i += 2) {
    cap[i] += low[i];
    cap[i ^ 1] -= low[i];
    audhsdf[i] += low[i];
    audhsdf[i ^ 1] -= low[i];
  }
  adj[source] = ant[adj[source]];
  adj[sink] = ant[adj[sink]];
  inde -= 2;
  return dinic(source, sink) + f;
}
pair<int, int> arr[N];
int xs[N], ys[N];
int dx[N], dy[N];
int qntx[N], qnty[N];
int pnt_id[N];
char ans[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int r, b;
  scanf("%d %d", &r, &b);
  char cheap = 'r', expensive = 'b';
  if (r > b) {
    swap(cheap, expensive);
    swap(r, b);
  }
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    arr[i] = pair<int, int>(x, y);
    xs[i] = x;
    ys[i] = y;
  }
  sort(xs, xs + n);
  int xssz = unique(xs, xs + n) - xs;
  sort(ys, ys + n);
  int yssz = unique(ys, ys + n) - ys;
  for (int i = 0; i < n; ++i) {
    arr[i].first = lower_bound(xs, xs + xssz, arr[i].first) - xs;
    arr[i].second = lower_bound(ys, ys + yssz, arr[i].second) - ys;
    ++qntx[arr[i].first];
    ++qnty[arr[i].second];
    ++dx[arr[i].first];
    ++dy[arr[i].second];
  }
  for (int i = 0; i < m; ++i) {
    int t, l, d;
    scanf("%d %d %d", &t, &l, &d);
    if (t == 1) {
      int k = lower_bound(xs, xs + xssz, l) - xs;
      if (xs[k] == l) {
        dx[k] = min(dx[k], d);
      }
    } else {
      int k = lower_bound(ys, ys + yssz, l) - ys;
      if (ys[k] == l) {
        dy[k] = min(dy[k], d);
      }
    }
  }
  memset(adj, -1, sizeof adj);
  inde = 0;
  int source = xssz + yssz, sink = source + 1;
  for (int i = 0; i < xssz; ++i) {
    int l = (qntx[i] - dx[i] + 1) / 2;
    int r = (qntx[i] + dx[i]) / 2;
    if (l > r) {
      puts("-1");
      return 0;
    }
    add_edge(source, i, l, r);
  }
  for (int i = 0; i < n; ++i) {
    pnt_id[i] = inde;
    add_edge(arr[i].first, arr[i].second + xssz, 0, 1);
  }
  for (int i = 0; i < yssz; ++i) {
    int l = (qnty[i] - dy[i] + 1) / 2;
    int r = (qnty[i] + dy[i]) / 2;
    if (l > r) {
      puts("-1");
      return 0;
    }
    add_edge(i + xssz, sink, l, r);
  }
  if (max_flow(source, sink) < 0) {
    puts("-1");
    return 0;
  }
  long long qnt = 0;
  for (int i = 0; i < n; ++i) {
    int id = pnt_id[i];
    if (audhsdf[id] > 0)
      ans[i] = cheap, ++qnt;
    else
      ans[i] = expensive;
  }
  printf("%lld\n", qnt * r + (n - qnt) * b);
  printf("%s\n", ans);
  return 0;
}
