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 double pi = acos(-1.0);
const double eps = 1e-9;
const int INF = 1E9;
const int MAXN = 100500;
string shield = "br";
struct edge {
  int from, to;
  int L, R, f, pos;
  int inv;
  edge(int _from, int _to, int _L, int _R, int _pos, int _inv) {
    from = _from;
    to = _to;
    L = _L;
    R = _R;
    f = 0;
    pos = _pos;
    inv = _inv;
  }
};
int n, m, r, b, t, x, y;
int S, F, sz, S2, F2;
vector<vector<int> > g, gg;
vector<int> ptr;
vector<edge> lst, lst2;
map<int, int> idx, idy, rx, ry;
pair<int, int> a[MAXN];
vector<int> cx, cy;
map<int, int> qx, qy;
long long ans;
vector<int> dist;
queue<int> q;
int color[MAXN];
bool bfs(int S, int F) {
  dist.clear();
  dist.resize(sz, INF);
  dist[S] = 0;
  while (!q.empty()) q.pop();
  q.push(S);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto eid : g[v]) {
      int w = lst[eid].to;
      if (lst[eid].f < lst[eid].R && dist[w] == INF) {
        dist[w] = dist[v] + 1;
        q.push(w);
      }
    }
  }
  return dist[F] < INF;
}
int dfs(int v, int F) {
  if (v == F) return 1;
  for (ptr[v]; ptr[v] < (int)g[v].size(); ptr[v]++) {
    int eid = g[v][ptr[v]];
    int w = lst[eid].to;
    if (dist[v] + 1 == dist[w] && lst[eid].f < lst[eid].R) {
      if (dfs(w, F)) {
        lst[eid].f++;
        lst[lst[eid].inv].f--;
        return 1;
      }
    }
  }
  return 0;
}
int lastEdge;
int dinic(int S, int F) {
  int res = 0;
  while (bfs(S, F)) {
    ptr.clear();
    ptr.resize(sz, 0);
    while (dfs(S, F)) {
      res++;
    }
  }
  return res;
}
int addEdge(int u, int v, int R, int pos) {
  gg[u].push_back(lst2.size());
  gg[v].push_back(lst2.size() + 1);
  lst2.push_back(edge(u, v, 0, R, pos, lst2.size() + 1));
  lst2.push_back(edge(v, u, 0, 0, -1, lst2.size() - 1));
  return (int)lst2.size() - 2;
}
void rebuildNet() {
  S2 = sz++;
  F2 = sz++;
  gg.resize(sz);
  for (auto e : lst) {
    if (e.L > e.R) {
      cout << -1 << '\n';
      exit(0);
    }
    int u = e.from;
    int v = e.to;
    addEdge(S2, v, e.L, -1);
    addEdge(u, F2, e.L, -1);
    addEdge(u, v, e.R - e.L, e.pos);
  }
  lastEdge = addEdge(F, S, INF, -1);
  g = gg;
  lst = lst2;
}
int main() {
  cin >> n >> m >> r >> b;
  if (r > b) {
    swap(r, b);
    swap(shield[0], shield[1]);
  }
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    cx.push_back(a[i].first);
    cy.push_back(a[i].second);
    rx[a[i].first]++;
    ry[a[i].second]++;
  }
  sort((cx).begin(), (cx).end());
  cx.resize(unique((cx).begin(), (cx).end()) - cx.begin());
  for (auto x : cx) qx[x] = INF;
  sort((cy).begin(), (cy).end());
  cy.resize(unique((cy).begin(), (cy).end()) - cy.begin());
  for (auto y : cy) qy[y] = INF;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      qx[x] = min(qx[x], y);
    } else {
      qy[x] = min(qy[x], y);
    }
  }
  S = 0;
  F = 1;
  sz = 2;
  for (auto x : cx) idx[x] = sz++;
  for (auto y : cy) idy[y] = sz++;
  g.clear();
  g.resize(sz);
  for (auto x : cx) {
    g[S].push_back(lst.size());
    lst.push_back(edge(S, idx[x], max(0, (rx[x] - qx[x] + 1) / 2),
                       min(rx[x], (rx[x] + qx[x]) / 2), -1, -1));
  }
  for (int i = 0; i < (int)(n); i++) {
    g[idx[a[i].first]].push_back(lst.size());
    lst.push_back(edge(idx[a[i].first], idy[a[i].second], 0, 1, i, -1));
  }
  for (auto y : cy) {
    g[idy[y]].push_back(lst.size());
    lst.push_back(edge(idy[y], F, max(0, (ry[y] - qy[y] + 1) / 2),
                       min(ry[y], (ry[y] + qy[y]) / 2), -1, -1));
  }
  rebuildNet();
  int needFlow = 0;
  for (auto eid : g[S2]) needFlow += lst[eid].R;
  int flow = dinic(S2, F2);
  if (flow < needFlow) {
    cout << -1 << '\n';
    return 0;
  }
  assert(flow == needFlow);
  flow = dinic(S, F);
  long long ans = 1ll * flow * r + 1ll * (n - flow) * b;
  for (int eid = 0; eid < (int)(lst.size()); eid++)
    if (lst[eid].pos != -1) {
      int i = lst[eid].pos;
      color[i] = lst[eid].f;
    }
  cout << ans << '\n';
  string s = "";
  for (int i = 0; i < (int)(n); i++) s += shield[color[i]];
  cout << s << '\n';
  return 0;
}