#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int INF = 1E9;
const int MAXN = 100500;
string shield = "br";
struct edge {
  int from, to;
  int L, R, f, pos;
  int inv;
  edge(int _from, int _to, int _L, int _R, int _pos, int _inv) {
    from = _from;
    to = _to;
    L = _L;
    R = _R;
    f = 0;
    pos = _pos;
    inv = _inv;
  }
};
int n, m, r, b, t, x, y;
int S, F, sz, S2, F2;
vector<vector<int> > g, gg;
vector<int> ptr;
vector<edge> lst, lst2;
map<int, int> idx, idy, rx, ry;
pair<int, int> a[MAXN];
vector<int> cx, cy;
map<int, int> qx, qy;
long long ans;
vector<int> dist;
queue<int> q;
int color[MAXN];
bool bfs(int S, int F) {
  dist.clear();
  dist.resize(sz, INF);
  dist[S] = 0;
  while (!q.empty()) q.pop();
  q.push(S);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto eid : g[v]) {
      int w = lst[eid].to;
      if (lst[eid].f < lst[eid].R && dist[w] == INF) {
        dist[w] = dist[v] + 1;
        q.push(w);
      }
    }
  }
  return dist[F] < INF;
}
int dfs(int v, int F) {
  if (v == F) return 1;
  for (ptr[v]; ptr[v] < (int)g[v].size(); ptr[v]++) {
    int eid = g[v][ptr[v]];
    int w = lst[eid].to;
    if (dist[v] + 1 == dist[w] && lst[eid].f < lst[eid].R) {
      if (dfs(w, F)) {
        lst[eid].f++;
        lst[lst[eid].inv].f--;
        return 1;
      }
    }
  }
  return 0;
}
int lastEdge;
int dinic(int S, int F) {
  int res = 0;
  while (bfs(S, F)) {
    ptr.clear();
    ptr.resize(sz, 0);
    while (dfs(S, F)) {
      res++;
    }
  }
  return res;
}
int addEdge(int u, int v, int R, int pos) {
  gg[u].push_back(lst2.size());
  gg[v].push_back(lst2.size() + 1);
  lst2.push_back(edge(u, v, 0, R, pos, lst2.size() + 1));
  lst2.push_back(edge(v, u, 0, 0, -1, lst2.size() - 1));
  return (int)lst2.size() - 2;
}
void rebuildNet() {
  S2 = sz++;
  F2 = sz++;
  gg.resize(sz);
  for (auto e : lst) {
    if (e.L > e.R) {
      cout << -1 << '\n';
      exit(0);
    }
    int u = e.from;
    int v = e.to;
    addEdge(S2, v, e.L, -1);
    addEdge(u, F2, e.L, -1);
    addEdge(u, v, e.R - e.L, e.pos);
  }
  lastEdge = addEdge(F, S, INF, -1);
  g = gg;
  lst = lst2;
}
int main() {
  cin >> n >> m >> r >> b;
  if (r > b) {
    swap(r, b);
    swap(shield[0], shield[1]);
  }
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    cx.push_back(a[i].first);
    cy.push_back(a[i].second);
    rx[a[i].first]++;
    ry[a[i].second]++;
  }
  sort((cx).begin(), (cx).end());
  cx.resize(unique((cx).begin(), (cx).end()) - cx.begin());
  for (auto x : cx) qx[x] = INF;
  sort((cy).begin(), (cy).end());
  cy.resize(unique((cy).begin(), (cy).end()) - cy.begin());
  for (auto y : cy) qy[y] = INF;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      qx[x] = min(qx[x], y);
    } else {
      qy[x] = min(qy[x], y);
    }
  }
  S = 0;
  F = 1;
  sz = 2;
  for (auto x : cx) idx[x] = sz++;
  for (auto y : cy) idy[y] = sz++;
  g.clear();
  g.resize(sz);
  for (auto x : cx) {
    g[S].push_back(lst.size());
    lst.push_back(edge(S, idx[x], max(0, (rx[x] - qx[x] + 1) / 2),
                       min(rx[x], (rx[x] + qx[x]) / 2), -1, -1));
  }
  for (int i = 0; i < (int)(n); i++) {
    g[idx[a[i].first]].push_back(lst.size());
    lst.push_back(edge(idx[a[i].first], idy[a[i].second], 0, 1, i, -1));
  }
  for (auto y : cy) {
    g[idy[y]].push_back(lst.size());
    lst.push_back(edge(idy[y], F, max(0, (ry[y] - qy[y] + 1) / 2),
                       min(ry[y], (ry[y] + qy[y]) / 2), -1, -1));
  }
  rebuildNet();
  int needFlow = 0;
  for (auto eid : g[S2]) needFlow += lst[eid].R;
  int flow = dinic(S2, F2);
  if (flow < needFlow) {
    cout << -1 << '\n';
    return 0;
  }
  assert(flow == needFlow);
  flow = dinic(S, F);
  long long ans = 1ll * flow * r + 1ll * (n - flow) * b;
  for (int eid = 0; eid < (int)(lst.size()); eid++)
    if (lst[eid].pos != -1) {
      int i = lst[eid].pos;
      color[i] = lst[eid].f;
    }
  cout << ans << '\n';
  string s = "";
  for (int i = 0; i < (int)(n); i++) s += shield[color[i]];
  cout << s << '\n';
  return 0;
}
