#include <bits/stdc++.h>
using namespace std;
const int INF = 0xfffffff;
const int maxn = 1e6;
int head[maxn], head1[maxn];
int cnt;
vector<int> r;
vector<int> c;
pair<int, int> point[maxn];
int rcnt[maxn], ccnt[maxn];
int rflow[maxn], cflow[maxn];
char fangan[maxn];
struct edge {
  int from, to, next, flow;
  int pre;
  int pos;
} e[2 * maxn];
struct node {
  int op, l, d;
} ac[maxn];
void addedge(int from, int to, int flow, int pos = -1) {
  e[cnt].from = from;
  e[cnt].to = to;
  e[cnt].flow = flow;
  e[cnt].pre = -1;
  e[cnt].next = head[from];
  e[cnt].pos = pos;
  if (e[cnt].next != -1) {
    e[e[cnt].next].pre = cnt;
  }
  head[from] = cnt++;
}
int deep[maxn], gap[maxn], pre[maxn];
queue<int> q;
void bfs(int s, int t) {
  memset(deep, -1, sizeof(deep));
  memset(gap, 0, sizeof(gap));
  deep[t] = 0;
  gap[0] = 1;
  q.push(t);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = head[now]; i != -1; i = e[i].next) {
      if (deep[e[i].to] != -1) continue;
      deep[e[i].to] = deep[now] + 1;
      gap[deep[e[i].to]]++;
      q.push(e[i].to);
    }
  }
  return;
}
int sap(int s, int t, int ct) {
  bfs(s, t);
  for (int i = 0; i <= ct; i++) head1[i] = head[i];
  int v = pre[s] = s, flow = 0, ff = INF;
  while (deep[s] < ct) {
    int flag = 0;
    for (int &i = head1[v]; i != -1; i = e[i].next) {
      int u = e[i].to;
      if (e[i].flow && deep[v] == deep[u] + 1) {
        flag = 1;
        pre[u] = v;
        v = u;
        ff = min(ff, e[i].flow);
        if (v == t) {
          flow += ff;
          while (v != s) {
            v = pre[v];
            e[head1[v]].flow -= ff;
            e[head1[v] ^ 1].flow += ff;
          }
          ff = INF;
        }
        break;
      }
    }
    if (flag) continue;
    int minlevel = ct;
    for (int i = head[v]; i != -1; i = e[i].next) {
      int u = e[i].to;
      if (e[i].flow && deep[u] < minlevel) {
        minlevel = deep[u], head1[v] = i;
      }
    }
    if (--gap[deep[v]] == 0) break;
    deep[v] = minlevel + 1;
    gap[deep[v]]++;
    v = pre[v];
  }
  return flow;
}
void DEL(int x) {
  int pp = e[x].pre;
  int nn = e[x].next;
  if (pp == -1) {
    head[e[x].from] = e[x].next;
  } else {
    e[pp].next = e[x].next;
  }
  if (nn != -1) {
    e[nn].pre = pp;
  }
}
int get_idr(int x) {
  return lower_bound(r.begin(), r.end(), x) - r.begin() + 1;
}
int get_idc(int x) {
  return lower_bound(c.begin(), c.end(), x) - c.begin() + r.size() + 1;
}
void debug() {
  puts("");
  for (int i = 0; i < cnt; i++) {
    printf("%d %d %d\n", e[i].from, e[i].to, e[i].flow);
  }
}
void debug2(int n, int m) {
  for (int i = 0; i < n; i++) {
    int x = get_idr(point[i].first);
    int y = get_idc(point[i].second);
    printf("%d %d\n", x, y);
  }
  puts("");
  for (int i = 0; i < m; i++) {
    int x;
    if (ac[i].op == 1) {
      x = get_idr(ac[i].l);
    } else {
      x = get_idc(ac[i].l);
    }
    printf("%d %d %d\n", ac[i].op, x, ac[i].d);
  }
  puts("");
}
int main() {
  memset(head, -1, sizeof(head));
  cnt = 0;
  int n, m;
  int red, blue;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &red, &blue);
  char re = 'r', bl = 'b';
  if (red > blue) {
    swap(red, blue);
    swap(re, bl);
  }
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    point[i] = make_pair(x, y);
    r.push_back(x);
    c.push_back(y);
  }
  for (int i = 0; i < m; i++) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    ac[i].op = t, ac[i].l = l, ac[i].d = d;
    if (t == 1)
      r.push_back(l);
    else
      c.push_back(l);
  }
  sort(r.begin(), r.end());
  sort(c.begin(), c.end());
  r.erase(unique(r.begin(), r.end()), r.end());
  c.erase(unique(c.begin(), c.end()), c.end());
  int ct = r.size() + c.size();
  int s = 0, t = ct + 1, ss = ct + 2, tt = ct + 3;
  for (int i = 0; i < n; i++) {
    int x = get_idr(point[i].first);
    int y = get_idc(point[i].second);
    rcnt[x]++;
    ccnt[y]++;
    addedge(x, y, 1, i);
    addedge(y, x, 0, i);
  }
  for (int i = 1; i <= r.size(); i++) {
    rflow[i] = rcnt[i];
  }
  for (int i = r.size() + 1; i <= ct; i++) {
    cflow[i] = ccnt[i];
  }
  for (int i = 0; i < m; i++) {
    if (ac[i].op == 1) {
      int x = get_idr(ac[i].l);
      rflow[x] = min(rflow[x], ac[i].d);
    } else {
      int x = get_idc(ac[i].l);
      cflow[x] = min(cflow[x], ac[i].d);
    }
  }
  long long sum = 0;
  for (int i = 1; i <= r.size(); i++) {
    int low = max((rcnt[i] - rflow[i] + 1) / 2, 0);
    int up = (rcnt[i] + rflow[i]) / 2;
    up = up - low;
    if (up < 0) {
      printf("-1\n");
      return 0;
    }
    addedge(s, i, up);
    addedge(i, s, 0);
    if (low) {
      addedge(s, tt, low);
      addedge(tt, s, 0);
      addedge(ss, i, low);
      addedge(i, ss, 0);
      sum += low;
    }
  }
  for (int i = r.size() + 1; i <= r.size() + c.size(); i++) {
    int low = max((ccnt[i] - cflow[i] + 1) / 2, 0);
    int up = (ccnt[i] + cflow[i]) / 2;
    up = up - low;
    if (up < 0) {
      printf("-1\n");
      return 0;
    }
    addedge(i, t, up);
    addedge(t, i, 0);
    if (low) {
      addedge(i, tt, low);
      addedge(tt, i, 0);
      addedge(ss, t, low);
      addedge(t, ss, 0);
      sum += low;
    }
  }
  int last = cnt;
  addedge(t, s, INF);
  addedge(s, t, 0);
  int as = sap(ss, tt, tt + 1);
  if (as < sum) {
    printf("-1\n");
    return 0;
  }
  sum = e[last ^ 1].flow;
  DEL(last);
  DEL(last ^ 1);
  as = sap(s, t, t + 1);
  sum = sum + as;
  long long ans = red * sum + blue * (n - sum);
  printf("%lld\n", ans);
  for (int i = 1; i <= r.size(); i++) {
    for (int j = head[i]; j != -1; j = e[j].next) {
      if (e[j].pos != -1) {
        if (e[j].flow == 0) {
          fangan[e[j].pos] = re;
        } else {
          fangan[e[j].pos] = bl;
        }
      }
    }
  }
  printf("%s\n", fangan);
}
