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 maxn = 210000;
const int inf = 0x3f3f3f3f;
const int maxm = maxn * 20;
struct edge {
  int to, cap, next;
} E[maxm];
int limitx[maxn], limity[maxn], cntx[maxn], cnty[maxn];
pair<int, int> A[maxn];
int head[maxn], si, level[maxn];
int start[maxn], node_cnt, now_level;
void add_edge(int u, int v, int cap) {
  if (cap == 0) return;
  E[si].to = v;
  E[si].next = head[u];
  E[si].cap = cap;
  head[u] = si++;
  E[si].to = u;
  E[si].next = head[v];
  E[si].cap = 0;
  head[v] = si++;
}
bool bfs(int s, int t) {
  memset(level, -1, sizeof(int) * node_cnt);
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while (!que.empty() && level[t] == -1) {
    int v = que.front();
    que.pop();
    for (int i = head[v]; ~i; i = E[i].next) {
      int u = E[i].to;
      if (u < node_cnt && level[u] == -1 && E[i].cap > 0) {
        level[u] = level[v] + 1;
        que.push(u);
      }
    }
  }
  return level[t] != -1;
}
int dfs(int v, int t, int f) {
  if (v == t) {
    return f;
  }
  int w = 0;
  for (int &i = start[v]; ~i; i = E[i].next) {
    int u = E[i].to;
    if (E[i].cap > 0 && level[u] == level[v] + 1) {
      int d = dfs(u, t, min(f - w, E[i].cap));
      w += d;
      E[i].cap -= d;
      E[i ^ 1].cap += d;
      if (f == w) {
        return w;
      }
    }
  }
  level[v] = -1;
  return w;
}
int max_flow(int s, int t) {
  int flow = 0;
  while (bfs(s, t)) {
    memcpy(start, head, sizeof(*head) * node_cnt);
    flow += dfs(s, t, INT_MAX);
  }
  return flow;
}
char C[maxn];
int used[maxn];
int main() {
  int n, m, red, blue;
  scanf("%d%d%d%d", &n, &m, &red, &blue);
  bool is_swap = false;
  if (red < blue) {
    swap(red, blue);
    is_swap = true;
  }
  vector<int> X, Y;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &A[i].first, &A[i].second);
    X.push_back(A[i].first);
    Y.push_back(A[i].second);
  }
  sort(X.begin(), X.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end());
  Y.erase(unique(Y.begin(), Y.end()), Y.end());
  memset(head, -1, sizeof head);
  si = 0;
  add_edge(2 * n + 1, 0, n);
  for (int i = 1; i <= n; i++) {
    int x = lower_bound(X.begin(), X.end(), A[i].first) - X.begin() + 1;
    int y = lower_bound(Y.begin(), Y.end(), A[i].second) - Y.begin() + 1;
    add_edge(x, y + n, 1);
    cntx[x]++;
    cnty[y]++;
  }
  for (int i = 1; i <= n; i++) {
    limitx[i] = cntx[i];
    limity[i] = cnty[i];
  }
  for (int i = 1, t, d, l; i <= m; i++) {
    scanf("%d%d%d", &t, &l, &d);
    if (t == 1) {
      int pos = lower_bound(X.begin(), X.end(), l) - X.begin();
      if (pos < X.size() && X[pos] == l) {
        pos++;
        limitx[pos] = min(limitx[pos], d);
      }
    } else {
      int pos = lower_bound(Y.begin(), Y.end(), l) - Y.begin();
      if (pos < Y.size() && Y[pos] == l) {
        pos++;
        limity[pos] = min(limity[pos], d);
      }
    }
  }
  int res = 0;
  int S = 2 * n + 2, T = 2 * n + 3;
  int flowS = 0, flowT = 0;
  node_cnt = 2 * n + 4;
  int nx = X.size(), ny = Y.size();
  for (int i = 1; i <= nx; i++) {
    int r = (cntx[i] + limitx[i]) / 2;
    int l = (cntx[i] - limitx[i] + 1) / 2;
    if (l > r) {
      printf("-1\n");
      return 0;
    }
    if (l < 0) l = 0;
    add_edge(0, i, r - l);
    add_edge(S, i, l);
    add_edge(0, T, l);
  }
  for (int i = 1; i <= ny; i++) {
    int r = (cnty[i] + limity[i]) / 2;
    int l = (cnty[i] - limity[i] + 1) / 2;
    if (l > r) {
      printf("-1\n");
      return 0;
    }
    if (l < 0) l = 0;
    add_edge(i + n, 2 * n + 1, r - l);
    add_edge(i + n, T, l);
    add_edge(S, 2 * n + 1, l);
  }
  assert(si < maxm);
  max_flow(S, T);
  for (int i = head[S]; ~i; i = E[i].next) {
    if (E[i].cap > 0) {
      puts("-1");
      return 0;
    }
  }
  long long ans = 0;
  E[1].cap = E[0].cap = 0;
  node_cnt -= 2;
  max_flow(0, 2 * n + 1);
  for (int i = head[0]; ~i; i = E[i].next) {
    if (E[i ^ 1].cap > 0) {
      ans += E[i ^ 1].cap;
    }
  }
  ans = red * 1LL * n + ans * (blue - red);
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    C[i] = 'r';
    if (E[i * 2 + 2].cap == 0) {
      C[i] = 'b';
    }
  }
  C[n] = '\0';
  if (is_swap) {
    for (int i = 0; i < n; i++) {
      if (C[i] == 'r')
        C[i] = 'b';
      else
        C[i] = 'r';
    }
  }
  printf("%s\n", C);
  return 0;
}