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 N = 3e5 + 10;
struct Dinic {
  int INF = 1e9 + 10;
  struct Edge {
    int to, c;
  };
  vector<Edge> E;
  vector<int> e[N];
  int dis[N], cur[N];
  int n;
  void init(int _n) {
    n = _n;
    memset(dis, -1, sizeof(dis[0]) * n);
    memset(cur, 0, sizeof(cur[0]) * n);
    for (int i = 0; i < n; ++i) e[i].clear();
  }
  int add(int u, int v, int w) {
    int ret = E.size();
    e[u].push_back(E.size());
    E.push_back(Edge{v, w});
    e[v].push_back(E.size());
    E.push_back(Edge{u, 0});
    return ret;
  }
  void add_bounded(int u, int v, int lo, int hi) {
    add(n - 2, v, lo);
    add(u, n - 1, lo);
    add(u, v, hi - lo);
  }
  bool bfs(int S, int T) {
    memset(dis, -1, sizeof(dis[0]) * n);
    queue<int> q;
    q.push(S);
    dis[S] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto i : e[v]) {
        int u = E[i].to;
        int w = E[i].c;
        if (w > 0 && dis[u] == -1) {
          q.push(u);
          dis[u] = dis[v] + 1;
        }
      }
    }
    if (dis[T] == -1) return 0;
    return 1;
  }
  int dfs(int v, int T, int mn) {
    if (v == T || mn == 0) return mn;
    for (int &i = cur[v], tmp; i < e[v].size(); ++i) {
      int u = E[e[v][i]].to;
      int w = E[e[v][i]].c;
      if (w > 0 && dis[u] == dis[v] + 1 && (tmp = dfs(u, T, min(mn, w)))) {
        E[e[v][i]].c -= tmp;
        E[e[v][i] ^ 1].c += tmp;
        return tmp;
      }
    }
    return 0;
  }
  int dinic(int S, int T) {
    int tmp = 0, ret = 0;
    while (bfs(S, T)) {
      memset(cur, 0, sizeof(cur[0]) * n);
      while (tmp = dfs(S, T, INF)) ret += tmp;
    }
    return ret;
  }
  int flow(int S, int T) { return dinic(S, T); }
  bool feasible_bounded() {
    flow(n - 2, n - 1);
    for (auto it : e[n - 2]) {
      if (E[it].c) return false;
    }
    return true;
  }
  int mx_flow_bounded(int S, int T) {
    add(T, S, INF);
    bool ok = feasible_bounded();
    int ret = E[e[S].back()].c;
    e[S].pop_back(), e[T].pop_back();
    E.pop_back(), E.pop_back();
    return ok ? ret + flow(S, T) : -1;
  }
} dinic;
int n, m, r, b;
int x[N], y[N], t[N], l[N], d[N];
int lx[N], rx[N], ly[N], ry[N];
int cntx[N], cnty[N], id[N];
char ans[N];
vector<int> vx, vy;
int getlw(int d, int tot) {
  d = min(d, tot);
  return (tot - d + 1) / 2;
}
int gethi(int d, int tot) {
  d = min(d, tot);
  return (tot + d) / 2;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  dinic.init(2 * n + 5);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", t + i, l + i, d + i);
  }
  sort(vx.begin(), vx.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  sort(vy.begin(), vy.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  fill(rx, rx + vx.size(), dinic.INF);
  fill(ry, ry + vy.size(), dinic.INF);
  for (int i = 0; i < n; ++i) {
    x[i] = lower_bound(vx.begin(), vx.end(), x[i]) - vx.begin();
    y[i] = lower_bound(vy.begin(), vy.end(), y[i]) - vy.begin();
  }
  for (int i = 0; i < n; ++i) {
    cntx[x[i]]++;
    cnty[y[i]]++;
  }
  for (int i = 0; i < m; ++i) {
    if (t[i] == 1) {
      int id = lower_bound(vx.begin(), vx.end(), l[i]) - vx.begin();
      if (id >= vx.size() || vx[id] != l[i]) continue;
      l[i] = id;
      lx[l[i]] = max(lx[l[i]], getlw(d[i], cntx[l[i]]));
      rx[l[i]] = min(rx[l[i]], gethi(d[i], cntx[l[i]]));
    } else {
      int id = lower_bound(vy.begin(), vy.end(), l[i]) - vy.begin();
      if (id >= vy.size() || vy[id] != l[i]) continue;
      l[i] = id;
      ly[l[i]] = max(ly[l[i]], getlw(d[i], cnty[l[i]]));
      ry[l[i]] = min(ry[l[i]], gethi(d[i], cnty[l[i]]));
    }
  }
  int S = 2 * n, T = 2 * n + 1;
  for (int i = 0; i < n; ++i) {
    id[i] = dinic.add(x[i], y[i] + n, 1);
  }
  for (int i = 0; i < vx.size(); ++i) {
    if (lx[i] > rx[i]) return puts("-1"), 0;
    dinic.add_bounded(S, i, lx[i], rx[i]);
  }
  for (int i = 0; i < vy.size(); ++i) {
    if (ly[i] > ry[i]) return puts("-1"), 0;
    dinic.add_bounded(i + n, T, ly[i], ry[i]);
  }
  int a = dinic.mx_flow_bounded(S, T);
  if (a < 0) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    ans[i] = (dinic.E[id[i]].c ^ (r < b)) ? 'r' : 'b';
  }
  printf("%lld\n", 1ll * a * min(r, b) + 1ll * (n - a) * max(r, b));
  for (int i = 0; i < n; ++i) {
    putchar(ans[i]);
  }
  putchar('\n');
  return 0;
}