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;
int n, m, s, t, S, T, r, b, cnt, a[310000], vis[310000], dep[310000],
    mn[310000], tot[310000], num[310000], maxflow;
bool flag, isy[310000];
int edgenum = 1, F[810000], V[810000], Next[810000], Head[310000], cur[310000];
map<int, int> mapx, mapy;
void addedge(int u, int v, int f) {
  V[++edgenum] = v;
  F[edgenum] = f;
  Next[edgenum] = Head[u];
  Head[u] = edgenum;
}
void Add(int u, int v, int f) {
  addedge(u, v, f);
  addedge(v, u, 0);
}
void Add2(int u, int v, int L, int R) {
  num[v] += L;
  num[u] -= L;
  Add(u, v, R - L);
}
queue<int> que;
bool bfs(int s, int t) {
  for (int i = 0; i <= cnt + 3; i++) vis[i] = false, dep[i] = INF;
  dep[s] = 0;
  vis[s] = true;
  que.push(s);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    vis[u] = false;
    for (int e = Head[u]; e; e = Next[e]) {
      int v = V[e];
      if (dep[v] > dep[u] + 1 && F[e]) {
        dep[v] = dep[u] + 1;
        if (!vis[v]) {
          que.push(v);
          vis[v] = true;
        }
      }
    }
  }
  return dep[t] != INF;
}
int dfs(int u, int flow, int s, int t) {
  if (u == t) {
    maxflow += flow;
    return flow;
  }
  int used = 0;
  for (int &e = cur[u]; e; e = Next[e]) {
    int v = V[e];
    if (F[e] && dep[v] == dep[u] + 1) {
      int minflow = dfs(v, min(flow - used, F[e]), s, t);
      F[e] -= minflow;
      F[e ^ 1] += minflow;
      used += minflow;
      if (used == flow) break;
    }
  }
  return used;
}
int dinic(int s, int t) {
  maxflow = 0;
  while (bfs(s, t)) {
    for (int i = 0; i <= cnt + 3; i++) cur[i] = Head[i];
    while (dfs(s, INF, s, t))
      ;
  }
  return maxflow;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  if (r > b) swap(r, b), flag = true;
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (!mapx[x]) {
      mapx[x] = ++cnt;
      mn[cnt] = INF;
    }
    if (!mapy[y]) {
      mapy[y] = ++cnt;
      mn[cnt] = INF;
      isy[cnt] = true;
    }
    x = mapx[x];
    y = mapy[y];
    Add(x, y, 1);
    tot[x]++;
    tot[y]++;
  }
  int op, d;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d", &x, &d);
      x = mapx[x];
      if (!x) continue;
      mn[x] = min(mn[x], d);
    } else {
      scanf("%d%d", &y, &d);
      y = mapy[y];
      if (!y) continue;
      mn[y] = min(mn[y], d);
    }
  }
  int s = cnt + 1, t = cnt + 2;
  int S = 0, T = cnt + 3;
  for (int i = 1; i <= cnt; i++) {
    mn[i] = min(mn[i], tot[i]);
    int L = (tot[i] - mn[i] + 1) >> 1, R = (tot[i] + mn[i]) >> 1;
    if (L > R) {
      puts("-1");
      return 0;
    }
    if (isy[i])
      Add2(i, t, L, R);
    else
      Add2(s, i, L, R);
  }
  int tmp = 0;
  for (int i = 1; i <= cnt + 2; i++) {
    if (num[i] < 0) Add(i, T, -num[i]);
    if (num[i] > 0) Add(S, i, num[i]), tmp += num[i];
  }
  Add(t, s, INF);
  if (dinic(S, T) != tmp) {
    puts("-1");
    return 0;
  }
  int ans = dinic(s, t);
  printf("%lld\n", 1ll * ans * r + 1ll * (n - ans) * b);
  for (int i = 1; i <= n; i++) {
    if (F[i << 1] == flag)
      putchar('r');
    else
      putchar('b');
  }
  return 0;
}