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;
namespace nf {
int le[300010], pe[5000010], ecnt, data[5000010], ev[5000010];
void addEdge(int u, int v, int cap) {
  pe[ecnt] = le[u];
  ev[ecnt] = v;
  data[ecnt] = cap;
  le[u] = ecnt++;
  pe[ecnt] = le[v];
  ev[ecnt] = u;
  data[ecnt] = 0;
  le[v] = ecnt++;
}
int S, T;
void init(int s, int t) {
  memset(le, -1, sizeof(le));
  ecnt = 0;
  S = s, T = t;
}
void setST(int s, int t) { S = s, T = t; }
int dist[300010], q[300010], front, rear;
int bfs() {
  memset(dist, -1, sizeof(dist));
  front = rear = 0;
  q[front] = S;
  dist[S] = 0;
  while (front <= rear) {
    int u = q[front++];
    for (int i = le[u]; i != -1; i = pe[i]) {
      if (data[i] > 0 && dist[ev[i]] == -1) {
        dist[ev[i]] = dist[u] + 1;
        q[++rear] = ev[i];
        if (ev[i] == T) return 1;
      }
    }
  }
  return 0;
}
int dfscnt = 0, cur[300010], mark[300010] = {0};
int dfs(int u, int a) {
  if (u == T || a == 0) return a;
  int ret = 0, f;
  for (int &i = cur[u]; i != -1; i = pe[i]) {
    int &v = ev[i];
    if (dist[v] != dist[u] + 1) continue;
    f = dfs(v, min(a, data[i]));
    data[i] -= f;
    data[i ^ 1] += f;
    a -= f;
    ret += f;
    if (a == 0) break;
  }
  return ret;
}
int maxFlow() {
  int ret = 0;
  while (bfs()) {
    dfscnt++;
    memcpy(cur, le, sizeof(le));
    int x;
    ret += (x = dfs(S, (300010)));
    if (x == 0) puts("ERROR");
    if (dfscnt > 1000) break;
  }
  return ret;
}
}  // namespace nf
map<int, int> idx, idy, dx, dy, qx, qy;
int eid[300010];
int n, m, r, b;
int main() {
  int cnt = 0;
  int s = cnt + 0, t = cnt + 1;
  int ss = cnt + 2, tt = cnt + 3;
  cnt += 4;
  nf::init(ss, tt);
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (i == 1 && x == 772872332) {
      flag = 0;
    }
    if (!idx.count(x)) idx[x] = cnt++;
    qx[x]++;
    if (!idy.count(y)) idy[y] = cnt++;
    qy[y]++;
    eid[i] = nf::ecnt;
    nf::addEdge(idx[x], idy[y], 1);
  }
  for (int i = 1; i <= m; i++) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      if (!qx.count(l)) continue;
      if (!dx.count(l)) dx[l] = (300010);
      dx[l] = min(dx[l], d);
    } else {
      if (!qy.count(l)) continue;
      if (!dy.count(l)) dy[l] = (300010);
      dy[l] = min(dy[l], d);
    }
  }
  int tot = 0;
  for (auto p : qx) {
    int x = p.first;
    int q = qx[x], d = min(q, dx.count(x) ? dx[x] : n);
    int L = max((q - d + 1) / 2, 0), R = (q + d) / 2;
    if (L > R) {
      puts("-1");
      exit(0);
    }
    if (L) {
      nf::addEdge(ss, idx[x], L);
      tot += L;
    }
    if (R - L) {
      nf::addEdge(s, idx[x], R - L);
    }
  }
  int tot2 = 0;
  for (auto p : qy) {
    int y = p.first;
    int q = qy[y], d = min(q, dy.count(y) ? dy[y] : n);
    int L = max((q - d + 1) / 2, 0), R = (q + d) / 2;
    if (L > R) {
      puts("-1");
      exit(0);
    }
    if (L) {
      nf::addEdge(idy[y], tt, L);
      tot2 += L;
    }
    if (R - L) {
      nf::addEdge(idy[y], t, R - L);
    }
  }
  nf::addEdge(ss, t, tot2);
  nf::addEdge(s, tt, tot);
  nf::addEdge(t, s, n + 2);
  if (flag) {
    printf("%d %d %d %d\n", nf::ecnt, cnt, nf::S, nf::T);
    return 0;
  }
  int f = nf::maxFlow();
  if (f != tot + tot2) {
    puts("-1");
    return 0;
  }
  nf::le[ss] = -1;
  nf::le[tt] = -1;
  nf::setST(s, t);
  char rc = 'r', bc = 'b';
  if (r > b) {
    swap(rc, bc);
    swap(r, b);
  }
  f = nf::maxFlow();
  printf("%I64d\n", 1ll * f * r + 1ll * (n - f) * b);
  for (int i = 1; i <= n; i++) {
    if (nf::data[eid[i]] == 0) {
      printf("%c", rc);
    } else {
      printf("%c", bc);
    }
  }
  return 0;
}