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 N = 200005, E = (3 * N) * 2 + 2 * N;
int audhsdf[E], low[E], cap[E], to[E], ant[E], adj[N], delta[N];
int level[N], fila[N], copy_adj[N], inde;
void add_edge(int a, int b, int l, int u) {
  audhsdf[inde] = 0;
  to[inde] = b;
  low[inde] = l;
  cap[inde] = u;
  ant[inde] = adj[a];
  adj[a] = inde++;
  audhsdf[inde] = 0;
  to[inde] = a;
  low[inde] = 0;
  cap[inde] = 0;
  ant[inde] = adj[b];
  adj[b] = inde++;
}
bool bfs(int source, int sink) {
  memset(level, -1, sizeof level);
  level[source] = 0;
  int front = 0, size = 0, v;
  fila[size++] = source;
  while (front < size) {
    v = fila[front++];
    for (int i = adj[v]; ~i; i = ant[i]) {
      if (cap[i] > audhsdf[i] && level[to[i]] == -1) {
        level[to[i]] = level[v] + 1;
        fila[size++] = to[i];
      }
    }
  }
  return level[sink] != -1;
}
int dfs(int v, int sink, int f) {
  if (v == sink) return f;
  for (int& i = copy_adj[v]; ~i; i = ant[i]) {
    if (cap[i] > audhsdf[i] && level[to[i]] == level[v] + 1) {
      int aux = dfs(to[i], sink, min(f, cap[i] - audhsdf[i]));
      if (aux > 0) {
        audhsdf[i] += aux;
        audhsdf[i ^ 1] -= aux;
        return aux;
      }
    }
  }
  return 0;
}
int dinic(int source, int sink) {
  int ret = 0, audhsdf;
  while (bfs(source, sink)) {
    memcpy(copy_adj, adj, sizeof adj);
    while (audhsdf = dfs(source, sink, 1 << 30)) ret += audhsdf;
  }
  return ret;
}
int max_flow(int source, int sink) {
  memset(delta, 0, sizeof delta);
  for (int i = 0; i < inde; i += 2) {
    delta[to[i]] += low[i];
    delta[to[i ^ 1]] -= low[i];
    cap[i] -= low[i];
  }
  adj[sink + 1] = adj[sink + 2] = -1;
  int sum = 0;
  for (int i = 0; i <= sink; ++i) {
    if (delta[i] > 0) {
      add_edge(sink + 1, i, 0, delta[i]);
      sum += delta[i];
    } else if (delta[i] < 0) {
      add_edge(i, sink + 2, 0, -delta[i]);
    }
  }
  add_edge(sink, source, 0, INT_MAX);
  memset(audhsdf, 0, sizeof audhsdf);
  int f = dinic(sink + 1, sink + 2);
  if (f != sum) return -1;
  for (int i = 0; i < inde; i += 2) {
    cap[i] += low[i];
    cap[i ^ 1] -= low[i];
    audhsdf[i] += low[i];
    audhsdf[i ^ 1] -= low[i];
  }
  adj[source] = ant[adj[source]];
  adj[sink] = ant[adj[sink]];
  inde -= 2;
  return dinic(source, sink) + f;
}
pair<int, int> arr[N];
int xs[N], ys[N];
int dx[N], dy[N];
int qntx[N], qnty[N];
int pnt_id[N];
char ans[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int r, b;
  scanf("%d %d", &r, &b);
  char cheap = 'r', expensive = 'b';
  if (r > b) {
    swap(cheap, expensive);
    swap(r, b);
  }
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    arr[i] = pair<int, int>(x, y);
    xs[i] = x;
    ys[i] = y;
  }
  sort(xs, xs + n);
  int xssz = unique(xs, xs + n) - xs;
  sort(ys, ys + n);
  int yssz = unique(ys, ys + n) - ys;
  for (int i = 0; i < n; ++i) {
    arr[i].first = lower_bound(xs, xs + xssz, arr[i].first) - xs;
    arr[i].second = lower_bound(ys, ys + yssz, arr[i].second) - ys;
    ++qntx[arr[i].first];
    ++qnty[arr[i].second];
    ++dx[arr[i].first];
    ++dy[arr[i].second];
  }
  for (int i = 0; i < m; ++i) {
    int t, l, d;
    scanf("%d %d %d", &t, &l, &d);
    if (t == 1) {
      int k = lower_bound(xs, xs + xssz, l) - xs;
      if (xs[k] == l) {
        dx[k] = min(dx[k], d);
      }
    } else {
      int k = lower_bound(ys, ys + yssz, l) - ys;
      if (ys[k] == l) {
        dy[k] = min(dy[k], d);
      }
    }
  }
  memset(adj, -1, sizeof adj);
  inde = 0;
  int source = xssz + yssz, sink = source + 1;
  for (int i = 0; i < xssz; ++i) {
    int l = (qntx[i] - dx[i] + 1) / 2;
    int r = (qntx[i] + dx[i]) / 2;
    if (l > r) {
      puts("-1");
      return 0;
    }
    add_edge(source, i, l, r);
  }
  for (int i = 0; i < n; ++i) {
    pnt_id[i] = inde;
    add_edge(arr[i].first, arr[i].second + xssz, 0, 1);
  }
  for (int i = 0; i < yssz; ++i) {
    int l = (qnty[i] - dy[i] + 1) / 2;
    int r = (qnty[i] + dy[i]) / 2;
    if (l > r) {
      puts("-1");
      return 0;
    }
    add_edge(i + xssz, sink, l, r);
  }
  if (max_flow(source, sink) < 0) {
    puts("-1");
    return 0;
  }
  long long qnt = 0;
  for (int i = 0; i < n; ++i) {
    int id = pnt_id[i];
    if (audhsdf[id] > 0)
      ans[i] = cheap, ++qnt;
    else
      ans[i] = expensive;
  }
  printf("%lld\n", qnt * r + (n - qnt) * b);
  printf("%s\n", ans);
  return 0;
}