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;
struct flow_graph {
  int V, E, s, t;
  int *flow, *low, *cap, *to, *next, *last, *delta;
  int *dist, *q, *now, head, tail;
  flow_graph() {}
  flow_graph(int V, int E) {
    (*this).V = V;
    (*this).E = 0;
    int TE = 2 * (E + V + 1);
    flow = new int[TE];
    low = new int[TE];
    cap = new int[TE];
    to = new int[TE];
    next = new int[TE];
    last = new int[V + 2];
    delta = new int[V];
    dist = new int[V + 2];
    q = new int[V + 2];
    now = new int[V + 2];
  }
  void clear(int V) {
    (*this).V = V;
    (*this).E = 0;
    fill(last, last + V, -1);
  }
  void add_edge(int a, int b, int l, int u) {
    to[E] = b;
    low[E] = l;
    cap[E] = u;
    flow[E] = 0;
    next[E] = last[a];
    last[a] = E++;
    to[E] = a;
    low[E] = 0;
    cap[E] = 0;
    flow[E] = 0;
    next[E] = last[b];
    last[b] = E++;
  }
  bool bfs() {
    fill(dist, dist + V + 2, -1);
    head = tail = 0;
    q[tail] = t;
    ++tail;
    dist[t] = 0;
    while (head < tail) {
      int v = q[head];
      ++head;
      for (int e = last[v]; e != -1; e = next[e]) {
        if (cap[e ^ 1] > flow[e ^ 1] && dist[to[e]] == -1) {
          q[tail] = to[e];
          ++tail;
          dist[to[e]] = dist[v] + 1;
        }
      }
    }
    return dist[s] != -1;
  }
  int dfs(int v, int f) {
    if (v == t) return f;
    for (int &e = now[v]; e != -1; e = next[e]) {
      if (cap[e] > flow[e] && dist[to[e]] == dist[v] - 1) {
        int ret = dfs(to[e], min(f, cap[e] - flow[e]));
        if (ret > 0) {
          flow[e] += ret;
          flow[e ^ 1] -= ret;
          return ret;
        }
      }
    }
    return 0;
  }
  int max_flow(int source, int sink) {
    fill(delta, delta + V, 0);
    for (int e = 0; e < E; e += 2) {
      delta[to[e ^ 1]] -= low[e];
      delta[to[e]] += low[e];
      cap[e] -= low[e];
    }
    last[V] = last[V + 1] = -1;
    int sum = 0;
    for (int i = 0; i < V; ++i) {
      if (delta[i] > 0) {
        add_edge(V, i, 0, delta[i]);
        sum += delta[i];
      }
      if (delta[i] < 0) add_edge(i, V + 1, 0, -delta[i]);
    }
    add_edge(sink, source, 0, INT_MAX);
    s = V;
    t = V + 1;
    int f = 0, df;
    fill(flow, flow + E, 0);
    while (bfs()) {
      for (int i = V + 1; i >= 0; --i) now[i] = last[i];
      while (true) {
        df = dfs(s, INT_MAX);
        if (df == 0) break;
        f += df;
      }
    }
    if (f != sum) return -1;
    for (int e = 0; e < E; e += 2) {
      cap[e] += low[e];
      flow[e] += low[e];
      flow[e ^ 1] -= low[e];
      cap[e ^ 1] -= low[e];
    }
    s = source;
    t = sink;
    last[s] = next[last[s]];
    last[t] = next[last[t]];
    E -= 2;
    while (bfs()) {
      for (int i = V - 1; i >= 0; --i) now[i] = last[i];
      while (true) {
        df = dfs(s, INT_MAX);
        if (df == 0) break;
        f += df;
      }
    }
    return f;
  }
};
const int N = 100005;
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);
      }
    }
  }
  flow_graph fg = flow_graph(xssz + yssz + 2, n + xssz + yssz);
  fg.clear(xssz + yssz + 2);
  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;
    }
    fg.add_edge(source, i, l, r);
  }
  for (int i = 0; i < n; ++i) {
    pnt_id[i] = fg.E;
    fg.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;
    }
    fg.add_edge(i + xssz, sink, l, r);
  }
  if (fg.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 (fg.flow[id] > 0)
      ans[i] = cheap, ++qnt;
    else
      ans[i] = expensive;
  }
  printf("%lld\n", qnt * r + (n - qnt) * b);
  printf("%s\n", ans);
  return 0;
}