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 = 0x3f3f3f3f;
const int N = 200010;
const int M = 1000010;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return x * f;
}
int ea[M], eb[M], ec[N], cur[N], ef[M], etot, dis[N], S, T, need[N];
bool vis[N];
void add(int x, int y, int f) {
  etot++;
  ea[etot] = y;
  eb[etot] = ec[x];
  ec[x] = etot;
  ef[etot] = f;
}
void addEdge(int x, int y, int f) {
  add(x, y, f);
  add(y, x, 0);
}
void addBound(int x, int y, int l, int r) {
  need[y] += l;
  need[x] -= l;
  addEdge(x, y, r - l);
}
bool bfs() {
  queue<int> q;
  q.push(S);
  memset(dis, 0, sizeof(dis));
  dis[S] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = ec[x]; ~i; i = eb[i]) {
      int y = ea[i];
      if (!dis[y] && ef[i]) {
        dis[y] = dis[x] + 1;
        if (y == T) return 1;
        q.push(y);
      }
    }
  }
  return 0;
}
int dfs(int x, int flow) {
  if (x == T) return flow;
  int rest = flow;
  for (int i = ec[x]; ~i && rest; i = eb[i]) {
    int y = ea[i];
    if (dis[y] == dis[x] + 1 && ef[i]) {
      int dlt = dfs(y, min(rest, ef[i]));
      if (!dlt) dis[y] = 0;
      rest -= dlt;
      ef[i] -= dlt;
      ef[i ^ 1] += dlt;
    }
  }
  return flow - rest;
}
int dinic() {
  int res = 0;
  while (bfs()) res += dfs(S, inf);
  return res;
}
map<int, int> mpx, mpy;
int ans[N], minx[N], cnt[N];
bool spc[N];
signed main() {
  int n = read(), m = read(), rc = read(), bc = read();
  bool flag = 0;
  memset(ec, -1, sizeof(ec));
  etot = 1;
  if (rc > bc) {
    swap(rc, bc);
    flag = 1;
  }
  int idx = 0;
  for (int i = 1; i <= n; ++i) {
    int x = read(), y = read();
    if (!mpx[x]) mpx[x] = ++idx, minx[idx] = inf;
    cnt[mpx[x]]++;
    if (!mpy[y]) mpy[y] = ++idx, minx[idx] = inf, spc[idx] = 1;
    cnt[mpy[y]]++;
    addEdge(mpx[x], mpy[y], 1);
    ans[i] = etot;
  }
  while (m-- > 0) {
    int op = read(), x = read(), v = read();
    if (op == 1) {
      x = mpx[x];
      if (!x) continue;
      minx[x] = min(minx[x], v);
    } else {
      x = mpy[x];
      if (!x) continue;
      minx[x] = min(minx[x], v);
    }
  }
  int s = idx + 1, t = s + 1;
  T = t + 1;
  for (int i = 1; i <= idx; ++i) {
    int c = cnt[i], d = min(minx[i], c), l = (c - d + 1) >> 1, r = (c + d) >> 1;
    if (l > r) {
      puts("-1");
      return 0;
    }
    if (!spc[i])
      addBound(s, i, l, r);
    else
      addBound(i, t, l, r);
  }
  int nsum = 0;
  for (int i = S + 1; i <= T - 1; ++i) {
    if (need[i] < 0) addEdge(i, T, -need[i]);
    if (need[i] > 0) addEdge(S, i, need[i]), nsum += need[i];
  }
  addEdge(t, s, inf);
  if (dinic() != nsum) {
    puts("-1");
    return 0;
  }
  S = s;
  T = t;
  int res = dinic();
  printf("%lld\n", 1LL * res * rc + 1LL * (n - res) * bc);
  for (int i = 1; i <= n; ++i) {
    if (ef[ans[i]] ^ flag)
      putchar('r');
    else
      putchar('b');
  }
  return 0;
}