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;
int gi() {
  int res = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return res * w;
}
const int INF = 1e9;
const int MAX_N = 2e5 + 5;
struct Graph {
  int to, cap, id, next;
} e[MAX_N << 4];
int fir[MAX_N << 1], e_cnt;
void clearGraph() {
  memset(fir, -1, sizeof(fir));
  e_cnt = 0;
}
void Add_Edge(int u, int v, int c, int id = 0) {
  e[e_cnt] = (Graph){v, c, id, fir[u]}, fir[u] = e_cnt++;
  e[e_cnt] = (Graph){u, 0, 0, fir[v]}, fir[v] = e_cnt++;
}
int S, T, V, iter[MAX_N << 1], level[MAX_N << 1];
bool bfs() {
  static queue<int> que;
  for (int i = 0; i <= V; i++) level[i] = -1, iter[i] = fir[i];
  level[S] = 0, que.push(S);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = fir[x]; ~i; i = e[i].next) {
      int v = e[i].to;
      if (~level[v] || !e[i].cap) continue;
      level[v] = level[x] + 1, que.push(v);
    }
  }
  return ~level[T];
}
int dfs(int x, int f) {
  if (x == T || !f) return f;
  int res = 0;
  for (int &i = iter[x]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (e[i].cap && level[v] == level[x] + 1) {
      int d = dfs(v, min(f, e[i].cap));
      if (d) {
        e[i].cap -= d, e[i ^ 1].cap += d;
        res += d, f -= d;
        if (!f) break;
      }
    }
  }
  if (!res) level[x] = -1;
  return res;
}
int dinic() {
  int res = 0;
  while (bfs()) res += dfs(S, INF);
  return res;
}
struct lsh {
  int o[MAX_N], cnt;
  void ins(int x) { o[++cnt] = x; }
  void build() {
    sort(&o[1], &o[cnt + 1]);
    cnt = unique(&o[1], &o[cnt + 1]) - o - 1;
  }
  int find(int x) {
    int p = lower_bound(&o[1], &o[cnt + 1], x) - o;
    return o[p] == x ? p : -1;
  }
} X, Y;
int N, M, R, B, x[MAX_N], y[MAX_N];
int buc[MAX_N], mn[MAX_N], deg[MAX_N];
int main() {
  clearGraph();
  N = gi(), M = gi(), R = gi(), B = gi();
  for (int i = 1; i <= N; i++)
    x[i] = gi(), y[i] = gi(), X.ins(x[i]), Y.ins(y[i]);
  for (int i = 1; i <= N << 1; i++) mn[i] = INF;
  X.build(), Y.build();
  for (int i = 1; i <= N; i++) x[i] = X.find(x[i]), y[i] = Y.find(y[i]);
  for (int i = 1; i <= N; i++)
    Add_Edge(x[i], y[i] + X.cnt, 1, i), buc[x[i]]++, buc[y[i] + X.cnt]++;
  for (int i = 1; i <= M; i++) {
    int op = gi(), l = gi(), d = gi(), id;
    if (op == 1)
      id = X.find(l);
    else
      id = Y.find(l);
    if (id == -1) continue;
    if (op == 1)
      mn[id] = min(mn[id], d);
    else
      mn[id + X.cnt] = min(mn[id + X.cnt], d);
  }
  V = X.cnt + Y.cnt + 3;
  int s = 0, t = X.cnt + Y.cnt + 1;
  S = t + 1, T = S + 1;
  for (int i = 1; i <= X.cnt + Y.cnt; i++) {
    int l = max(0, (buc[i] - mn[i] + 1) / 2),
        r = min(buc[i], (mn[i] + buc[i]) / 2);
    if (l > r) return puts("-1") & 0;
    if (i <= X.cnt)
      Add_Edge(s, i, r - l), deg[s] += l, deg[i] -= l;
    else
      Add_Edge(i, t, r - l), deg[i] += l, deg[t] -= l;
  }
  int flow = 0;
  for (int i = 0; i <= V; i++)
    if (deg[i] < 0)
      Add_Edge(S, i, -deg[i]), flow += -deg[i];
    else if (deg[i] > 0)
      Add_Edge(i, T, deg[i]);
  Add_Edge(t, s, INF);
  if (dinic() != flow) return puts("-1") & 0;
  S = s, T = t, flow = dinic();
  printf("%lld\n", 1ll * flow * min(B, R) + 1ll * (N - flow) * max(B, R));
  for (int i = 0; i < e_cnt; i++) buc[e[i].id] = e[i ^ 1].cap;
  for (int i = 1; i <= N; i++)
    if (R < B)
      putchar(buc[i] ? 'r' : 'b');
    else
      putchar(buc[i] ? 'b' : 'r');
  putchar('\n');
  return 0;
}