#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 20);
template <class FlowT>
struct max_flow {
  const static FlowT finf = 1e18 + 42 + 17;
  const static FlowT feps = 0;
  struct edge {
    FlowT flow, cap;
    int idx, rev, to;
    edge() {
      flow = 0;
      cap = 0;
      rev = 0;
      idx = 0;
      to = 0;
    }
    edge(int _to, int _rev, FlowT _flow, FlowT _cap, int _idx) {
      to = _to;
      rev = _rev;
      flow = _flow;
      cap = _cap;
      idx = _idx;
    }
  };
  vector<edge> G[MAXN];
  int n, dist[MAXN], po[MAXN];
  bool bfs(int s, int t) {
    dist[s] = -1, po[s] = 0;
    dist[t] = -1, po[t] = 0;
    for (int v = 0; v <= n; v++) dist[v] = -1, po[v] = 0;
    queue<int> Q;
    Q.push(s);
    dist[s] = 0;
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      for (edge e : G[u])
        if (dist[e.to] == -1 && e.flow < e.cap) {
          dist[e.to] = dist[u] + 1;
          Q.push(e.to);
        }
    }
    return dist[t] != -1;
  }
  FlowT dfs(int u, int t, FlowT fl = finf) {
    if (u == t) return fl;
    for (; po[u] < G[u].size(); po[u]++) {
      auto &e = G[u][po[u]];
      if (dist[e.to] == dist[u] + 1 && e.flow < e.cap) {
        FlowT f = dfs(e.to, t, min(fl, e.cap - e.flow));
        e.flow += f;
        G[e.to][e.rev].flow -= f;
        if (f > 0) return f;
      }
    }
    return 0;
  }
  void init(int _n) { n = _n; }
  void add_edge(int u, int v, FlowT w, int idx = -1) {
    G[u].push_back(edge(v, G[v].size(), 0, w, idx));
    G[v].push_back(edge(u, G[u].size() - 1, 0, 0, -1));
  }
  FlowT flow(int s, int t) {
    if (s == t) return finf;
    FlowT ret = 0, to_add;
    while (bfs(s, t))
      while (to_add = dfs(s, t)) ret += to_add;
    return ret;
  }
};
int n, m;
max_flow<int64_t> mf;
pair<int64_t, int64_t> a[MAXN];
int64_t r, b;
void read() {
  cin >> n >> m;
  cin >> r >> b;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
}
vector<int64_t> all_idx;
map<int64_t, int64_t> low, high, cnt;
int ans[MAXN];
void solve() {
  for (int i = 0; i < n; i++) {
    all_idx.push_back(a[i].first);
    all_idx.push_back(1e9 + 42ll + a[i].second);
    cnt[a[i].first]++;
    cnt[a[i].second + 42ll + 1e9]++;
    high[a[i].first]++;
    high[a[i].second + 42ll + 1e9]++;
  }
  for (int i = 0; i < m; i++) {
    int t, l, d;
    cin >> t >> l >> d;
    if (t == 2) l += 1e9 + 42;
    all_idx.push_back(l);
    int64_t lo = (cnt[l] - d + 1) / 2, hi = (cnt[l] + d) / 2;
    lo = max(lo, (int64_t)0ll);
    hi = min(hi, cnt[l]);
    if (!low.count(l))
      low[l] = lo;
    else
      low[l] = max(low[l], lo);
    if (!high.count(l))
      high[l] = hi;
    else
      high[l] = min(high[l], hi);
  }
  sort(all_idx.begin(), all_idx.end());
  all_idx.erase(unique(all_idx.begin(), all_idx.end()), all_idx.end());
  mf.init(all_idx.size() + 42);
  for (int i = 0; i < n; i++) {
    int x = lower_bound(all_idx.begin(), all_idx.end(), (int64_t)a[i].first) -
            all_idx.begin();
    int y = lower_bound(all_idx.begin(), all_idx.end(),
                        (int64_t)a[i].second + 1e9 + 42ll) -
            all_idx.begin();
    mf.add_edge(x, y, 1, i);
  }
  int s = all_idx.size() + 1, t = all_idx.size() + 2, S = MAXN - 1,
      T = MAXN - 2;
  int64_t sum_low = 0;
  mf.add_edge(t, s, mf.finf);
  for (int i = 0; i < all_idx.size(); i++) {
    int64_t P = all_idx[i];
    if (low[P] > high[P]) {
      cout << -1 << '\n';
      return;
    }
    if (P >= 1e9 + 42ll) {
      mf.add_edge(i, t, high[P] - low[P]);
      mf.add_edge(i, T, low[P]);
      mf.add_edge(S, t, low[P]);
    } else {
      mf.add_edge(s, i, high[P] - low[P]);
      mf.add_edge(S, i, low[P]);
      mf.add_edge(s, T, low[P]);
    }
    sum_low += low[P];
  }
  if (mf.flow(S, T) != sum_low) {
    cout << -1 << '\n';
    return;
  }
  int swap_letters = 0;
  if (r > b) swap_letters = 1;
  mf.flow(s, t);
  int64_t res = 0;
  for (int u = 0; u <= mf.n; u++)
    for (auto e : mf.G[u])
      if (e.idx != -1) {
        ans[e.idx] = e.flow ^ swap_letters;
        if (ans[e.idx])
          res += r;
        else
          res += b;
      }
  cout << res << '\n';
  for (int i = 0; i < n; i++)
    if (ans[i])
      cout << "r";
    else
      cout << "b";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
