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;
struct EDGE {
  int to;
  int capacity;
  EDGE *rev;
  EDGE(int to, int capacity) : to(to), capacity(capacity) {}
};
struct LRFLOW {
  int n, src, snk, asrc, asnk;
  vector<vector<EDGE *>> G;
  vector<int> level, work;
  LRFLOW(int n, int src, int snk, int asrc, int asnk)
      : n(n), src(src), snk(snk), asrc(asrc), asnk(asnk) {
    G.resize(n + 1);
    level.resize(n + 1);
    work.resize(n + 1);
  }
  EDGE *add_edge(int u, int v, int capacity) {
    EDGE *ori = new EDGE(v, capacity);
    EDGE *rev = new EDGE(u, 0);
    ori->rev = rev;
    rev->rev = ori;
    G[u].push_back(ori);
    G[v].push_back(rev);
    return ori;
  }
  EDGE *add_lredge(int u, int v, int lower, int upper) {
    if (lower) {
      add_edge(asrc, v, lower);
      add_edge(u, asnk, lower);
    }
    return add_edge(u, v, upper - lower);
  }
  bool bfs(int src, int snk) {
    fill(level.begin(), level.end(), -1);
    queue<int> Q;
    level[src] = 0;
    Q.push(src);
    while (!Q.empty()) {
      int cur = Q.front();
      Q.pop();
      for (auto child : G[cur]) {
        if (child->capacity && level[child->to] == -1) {
          level[child->to] = level[cur] + 1;
          Q.push(child->to);
        }
      }
    }
    return level[snk] != -1;
  }
  int dfs(int cur, int snk, int flow) {
    if (cur == snk) return flow;
    for (int &i = work[cur]; i < (int)G[cur].size(); i++) {
      auto child = G[cur][i];
      if (child->capacity && level[child->to] == level[cur] + 1) {
        int min_capacity = dfs(child->to, snk, min(flow, child->capacity));
        if (min_capacity) {
          child->capacity -= min_capacity;
          child->rev->capacity += min_capacity;
          return min_capacity;
        }
      }
    }
    return 0;
  }
  int flow(int src, int snk) {
    int total_flow = 0;
    while (bfs(src, snk)) {
      fill(work.begin(), work.end(), 0);
      while (1) {
        int flow = dfs(src, snk, (int)2e9);
        if (flow)
          total_flow += flow;
        else
          break;
      }
    }
    return total_flow;
  }
};
int N, M, R, B;
int X[100001], Y[100001], LX[100001], UX[100001], LY[100001], UY[100001],
    CX[100001], CY[100001];
vector<int> vx, vy;
EDGE *edge[100001];
char s[100001];
int main(void) {
  scanf("%d %d %d %d", &N, &M, &R, &B);
  for (int i = 1; i <= N; i++) {
    scanf("%d %d", &X[i], &Y[i]);
    vx.push_back(X[i]);
    vy.push_back(Y[i]);
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  for (int i = 1; i <= N; i++) {
    X[i] = lower_bound(vx.begin(), vx.end(), X[i]) - vx.begin() + 1;
    Y[i] = lower_bound(vy.begin(), vy.end(), Y[i]) - vy.begin() + 1;
    UX[X[i]]++, UY[Y[i]]++;
    CX[X[i]]++, CY[Y[i]]++;
  }
  for (int i = 1; i <= M; i++) {
    int t, l, d;
    scanf("%d %d %d", &t, &l, &d);
    if (t == 1) {
      auto it = lower_bound(vx.begin(), vx.end(), l);
      if (it == vx.end() || *it != l) continue;
      int idx = it - vx.begin() + 1;
      LX[idx] = max(LX[idx], (CX[idx] - d + 1) / 2);
      UX[idx] = min(UX[idx], (CX[idx] + d) / 2);
      if (LX[idx] > UX[idx]) {
        printf("-1\n");
        return 0;
      }
    } else {
      auto it = lower_bound(vy.begin(), vy.end(), l);
      if (it == vy.end() || *it != l) continue;
      int idx = it - vy.begin() + 1;
      LY[idx] = max(LY[idx], (CY[idx] - d + 1) / 2);
      UY[idx] = min(UY[idx], (CY[idx] + d) / 2);
      if (LY[idx] > UY[idx]) {
        printf("-1\n");
        return 0;
      }
    }
  }
  int n = (int)vx.size();
  int m = (int)vy.size();
  int MAXV = n + m;
  LRFLOW lrflow(MAXV + 4, MAXV + 1, MAXV + 2, MAXV + 3, MAXV + 4);
  int D = 0;
  for (int i = 1; i <= n; i++) {
    D += LX[i];
    lrflow.add_lredge(lrflow.src, i, LX[i], UX[i]);
  }
  for (int i = 1; i <= m; i++) {
    D += LY[i];
    lrflow.add_lredge(n + i, lrflow.snk, LY[i], UY[i]);
  }
  for (int i = 1; i <= N; i++) edge[i] = lrflow.add_edge(X[i], n + Y[i], 1);
  lrflow.add_edge(lrflow.snk, lrflow.src, (int)2e9);
  if (lrflow.flow(lrflow.asrc, lrflow.asnk) != D) {
    printf("-1\n");
    return 0;
  }
  lrflow.flow(lrflow.src, lrflow.snk);
  for (int i = 1; i <= N; i++) {
    if (edge[i]->capacity == 0)
      s[i - 1] = R < B ? 'r' : 'b';
    else
      s[i - 1] = R < B ? 'b' : 'r';
  }
  long long res = 0;
  for (int i = 0; i < N; i++) res = res + (s[i] == 'r' ? R : B);
  printf("%lld\n", res);
  printf("%s\n", s);
  return 0;
}