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 i, j, m, n, p, k, in[210005], out[210005], ty, x[200005], y[200005], d, tot,
    sr[210005], sc[210005], st, ed, S, T, dis[210005], Q[210005], fox[210005],
    G[210005 * 10];
int Min[200005], Max[200005];
int ans[210005];
struct Node {
  int ed, before, flow;
} s[210005 * 10];
map<int, int> row, col;
map<int, int>::iterator it;
int bfs() {
  Q[Q[0] = 1] = st;
  memset(dis, -1, sizeof(dis));
  dis[st] = 0;
  int l = 1, i;
  for (; l <= Q[0] && dis[ed] == -1; ++l) {
    int p = Q[l];
    for (i = fox[p]; i; i = s[i].before)
      if (s[i].flow && dis[s[i].ed] == -1) {
        dis[s[i].ed] = dis[p] + 1;
        Q[++Q[0]] = s[i].ed;
      }
  }
  return dis[ed] != -1;
}
int dfs(int x, int flow) {
  if (x == ed) return flow;
  int i;
  int nowans = 0, a;
  for (i = fox[x]; i && flow; i = s[i].before)
    if (dis[s[i].ed] == dis[x] + 1 && s[i].flow) {
      a = dfs(s[i].ed, min(flow, s[i].flow));
      if (a) {
        nowans += a;
        flow -= a;
        s[i].flow -= a;
        s[i ^ 1].flow += a;
      }
    }
  if (!nowans) dis[x] = (int)1e9;
  return nowans;
}
int maxflow() {
  int j;
  int ans = 0;
  while (bfs()) {
    j = dfs(st, (int)1e9);
    while (j) {
      ans += j;
      j = dfs(st, (int)1e9);
    }
  }
  return ans;
}
int Rcost, Ccost, k1 = 1;
void add(int x, int y, int up, int down) {
  if (up > down) {
    puts("-1");
    exit(0);
  }
  out[x] += up;
  in[y] += up;
  down -= up;
  if (!down) return;
  s[++k1].ed = y;
  s[k1].before = fox[x];
  fox[x] = k1;
  s[k1].flow = down;
  s[++k1].ed = x;
  s[k1].before = fox[y];
  fox[y] = k1;
  s[k1].flow = 0;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &Rcost, &Ccost);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    if (!row[x[i]]) row[x[i]] = ++tot;
    if (!col[y[i]]) col[y[i]] = ++tot;
    sr[row[x[i]]]++;
    sc[col[y[i]]]++;
  }
  st = ++tot;
  ed = ++tot;
  S = ++tot;
  T = ++tot;
  for (i = 1; i <= tot; ++i) Min[i] = 0, Max[i] = n;
  for (i = 1; i <= m; ++i) {
    int x;
    scanf("%d%d%d", &ty, &x, &d);
    if (ty == 1) {
      if (!row[x]) continue;
      int ID = row[x];
      int res = (sr[ID] + d) / 2;
      Min[ID] = max(Min[ID], sr[ID] - res);
      Max[ID] = min(Max[ID], res);
    } else {
      if (!col[x]) continue;
      int ID = col[x];
      int res = (sc[ID] + d) / 2;
      Min[ID] = max(Min[ID], sc[ID] - res);
      Max[ID] = min(Max[ID], res);
    }
  }
  for (it = row.begin(); it != row.end(); ++it)
    if (it->second) add(S, it->second, Min[it->second], Max[it->second]);
  for (it = col.begin(); it != col.end(); ++it)
    if (it->second) add(it->second, T, Min[it->second], Max[it->second]);
  for (i = 1; i <= n; ++i) add(row[x[i]], col[y[i]], 0, 1), G[k1 - 1] = i;
  for (i = 1; i <= tot; ++i)
    if (in[i] > out[i])
      add(st, i, 0, in[i] - out[i]);
    else if (in[i] < out[i])
      add(i, ed, 0, out[i] - in[i]);
  add(T, S, 0, (int)1e9);
  maxflow();
  for (i = fox[st]; i; i = s[i].before)
    if (s[i].flow) {
      puts("-1");
      return 0;
    }
  st = S;
  ed = T;
  int ss = maxflow(), cnt = 0;
  printf("%I64d\n",
         1ll * ss * min(Rcost, Ccost) + 1ll * (n - ss) * max(Rcost, Ccost));
  for (it = row.begin(); it != row.end(); ++it) {
    int now = it->second;
    for (i = fox[now]; i; i = s[i].before)
      if (s[i].flow == 0) ans[G[i]] = 1, ++cnt;
  }
  char c, s;
  if (Rcost > Ccost)
    c = 'b', s = 'r';
  else
    c = 'r', s = 'b';
  for (i = 1; i <= n; ++i)
    if (ans[i])
      printf("%c", c);
    else
      printf("%c", s);
}