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 maxn = 200004;
const int inf = 1e9;
struct edge {
  int v, w, rev;
  edge() {}
  edge(int v, int w, int rev) : v(v), w(w), rev(rev) {}
};
vector<edge> adj[maxn];
int x[maxn], y[maxn];
int pu[maxn], iu[maxn];
int lx[maxn], dx[maxn];
int ly[maxn], dy[maxn];
int revx[maxn], revy[maxn];
int cntx[maxn], cnty[maxn];
int uni[maxn];
int n, m, X, Y;
int s, t, S, T;
int sum;
int dis[maxn], cure[maxn];
int max_flow();
int dinic(int s, int t);
bool bfs(int s, int t);
int dfs(int s, int flimit, int t);
void add(int u, int v, int w);
void add(int u, int v, int l, int r);
int main() {
  scanf("%d%d", &n, &m);
  int r, b;
  scanf("%d%d", &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
  }
  map<int, int> idx, idy;
  for (int i = 1; i <= m; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int tlx, tdx;
      scanf("%d%d", &tlx, &tdx);
      if (idx.count(tlx))
        dx[idx[tlx]] = min(dx[idx[tlx]], tdx);
      else {
        X++;
        idx[tlx] = X;
        lx[X] = tlx;
        dx[X] = tdx;
      }
    } else {
      int tly, tdy;
      scanf("%d%d", &tly, &tdy);
      if (idy.count(tly))
        dy[idy[tly]] = min(dy[idy[tly]], tdy);
      else {
        Y++;
        idy[tly] = Y;
        ly[Y] = tly;
        dy[Y] = tdy;
      }
    }
  }
  s = m + 1;
  t = m + 2;
  S = 0;
  T = m + 3;
  int *end;
  for (int i = 1; i <= n; i++) uni[i] = x[i];
  for (int i = 1; i <= X; i++) uni[i + n] = lx[i];
  sort(uni + 1, uni + 1 + n + X);
  end = unique(uni + 1, uni + 1 + n + X);
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(uni + 1, end, x[i]) - uni;
    revx[x[i]] = s;
  }
  for (int i = 1; i <= X; i++) {
    lx[i] = lower_bound(uni + 1, end, lx[i]) - uni;
    revx[lx[i]] = i;
  }
  for (int i = 1; i <= n; i++) uni[i] = y[i];
  for (int i = 1; i <= Y; i++) uni[i + n] = ly[i];
  sort(uni + 1, uni + 1 + n + Y);
  end = unique(uni + 1, uni + 1 + n + Y);
  for (int i = 1; i <= n; i++) {
    y[i] = lower_bound(uni + 1, end, y[i]) - uni;
    revy[y[i]] = t;
  }
  for (int i = 1; i <= Y; i++) {
    ly[i] = lower_bound(uni + 1, end, ly[i]) - uni;
    revy[ly[i]] = X + i;
  }
  for (int i = 1; i <= n; i++) {
    if (revx[x[i]] != s) cntx[revx[x[i]]]++;
    if (revy[y[i]] != t) cnty[revy[y[i]] - X]++;
  }
  bool f = 0;
  for (int i = 1; i <= X; i++) {
    int l = max(0, (int)ceil((double)(cntx[i] - dx[i]) / 2));
    int r = (cntx[i] + dx[i]) / 2;
    if (l > r) {
      f = 1;
      break;
    }
    add(s, i, l, r);
  }
  for (int i = 1; i <= Y; i++) {
    int l = max(0, (int)ceil((double)(cnty[i] - dy[i]) / 2));
    int r = (cnty[i] + dy[i]) / 2;
    if (l > r) {
      f = 1;
      break;
    }
    add(X + i, t, l, r);
  }
  if (f) {
    printf("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    add(revx[x[i]], revy[y[i]], 1);
    pu[i] = revx[x[i]];
    iu[i] = adj[pu[i]].size() - 1;
  }
  int ans = max_flow();
  if (ans == -1) {
    printf("-1");
    return 0;
  }
  printf("%lld\n",
         (long long)min(r, b) * ans + (long long)max(r, b) * (n - ans));
  char c[2];
  if (min(r, b) == r)
    c[0] = 'r', c[1] = 'b';
  else
    c[0] = 'b', c[1] = 'r';
  for (int i = 1; i <= n; i++) {
    printf("%c", c[adj[pu[i]][iu[i]].w]);
  }
  return 0;
}
int max_flow() {
  add(t, s, inf);
  int idt = adj[t].size() - 1;
  int flow = dinic(S, T);
  if (flow < sum) return -1;
  int ans = adj[s][adj[t][idt].rev].w;
  adj[s][adj[t][idt].rev].w = 0;
  adj[t][idt].w = 0;
  ans += dinic(s, t);
  return ans;
}
int dinic(int s, int t) {
  int flow = 0;
  while (bfs(s, t)) {
    memset(cure, 0, sizeof(cure));
    flow += dfs(s, inf, t);
  }
  return flow;
}
bool bfs(int s, int t) {
  for (int i = S; i <= T; i++) {
    dis[i] = inf;
  }
  dis[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i].v;
      int w = adj[u][i].w;
      if (dis[v] <= dis[u] + 1 || w <= 0) continue;
      dis[v] = dis[u] + 1;
      q.push(v);
    }
  }
  return dis[t] < inf;
}
int dfs(int u, int flimit, int t) {
  if (u == t || flimit == 0) return flimit;
  int flow = 0;
  for (int &i = cure[u]; i < adj[u].size(); i++) {
    int v = adj[u][i].v;
    int w = adj[u][i].w;
    int rev = adj[u][i].rev;
    if (dis[v] != dis[u] + 1 || w <= 0) continue;
    int df = dfs(v, min(flimit - flow, w), t);
    adj[u][i].w -= df;
    adj[v][rev].w += df;
    flow += df;
    if (flow == flimit) break;
  }
  return flow;
}
void add(int u, int v, int w) {
  adj[u].push_back(edge(v, w, adj[v].size()));
  adj[v].push_back(edge(u, 0, adj[u].size() - 1));
}
void add(int u, int v, int l, int r) {
  add(S, v, l);
  add(u, T, l);
  add(u, v, r - l);
  sum += l;
}