Problem: Steve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are n shields in total, the i-th shield is located at point (xi, yi) of the coordinate plane. It's possible that two or more shields share the same location.

Steve wants to paint all these shields. He paints each shield in either red or blue. Painting a shield in red costs r dollars while painting it in blue costs b dollars.

Additionally, there are m constraints Steve wants to be satisfied. The i-th constraint is provided by three integers ti, li and di:

  * If ti = 1, then the absolute difference between the number of red and blue shields on line x = li should not exceed di. 
  * If ti = 2, then the absolute difference between the number of red and blue shields on line y = li should not exceed di. 



Steve gave you the task of finding the painting that satisfies all the condition and the total cost is minimum.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the number of shields and the number of constraints respectively.

The second line contains two integers r and b (1 ≤ r, b ≤ 109).

The next n lines contain the shields coordinates. The i-th of these lines contains two integers xi and yi (1 ≤ xi, yi ≤ 109).

The next m lines contain the constrains. The j-th of these lines contains three integers tj, lj and dj (1 ≤ tj ≤ 2, 1 ≤ lj ≤ 109, 0 ≤ dj ≤ n).

Output

If satisfying all the constraints is impossible print -1 in first and only line of the output.

Otherwise, print the minimum total cost in the first line of output. In the second line print a string of length n consisting of letters 'r' and 'b' only. The i-th character should be 'r' if the i-th shield should be painted red in the optimal answer and 'b' if it should be painted blue. The cost of painting shields in these colors should be equal the minimum cost you printed on the first line.

If there exist more than one optimal solution, print any of them.

Examples

Input

5 6
8 3
2 10
1 5
9 10
9 10
2 8
1 9 1
1 2 1
2 10 3
2 10 2
1 1 1
2 5 2


Output

25
rbrbb


Input

4 4
7 3
10 3
9 8
10 3
2 8
2 8 0
2 8 0
1 2 0
1 9 0


Output

-1

Solution (in CPP):

Solution:
#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);
}