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 Dinic {
  struct Edge {
    int to, flow, next;
  };
  vector<Edge> edges;
  vector<int> head, act, h;
  int S, D;
  void AddEdge(int from, int to, int f, int rev_f = 0) {
    edges.push_back({to, f, (int)edges.size()});
    swap(edges.back().next, head[from]);
    edges.push_back({from, rev_f, (int)edges.size()});
    swap(edges.back().next, head[to]);
  }
  bool bfs() {
    fill(h.begin(), h.end(), -1);
    h[S] = 0;
    vector<int> q = {S};
    for (int it = 0; it < q.size() && h[D] == -1; it++) {
      int nod = q[it];
      for (int i = head[nod]; i != -1; i = edges[i].next)
        if (edges[i].flow && h[edges[i].to] == -1)
          h[edges[i].to] = 1 + h[nod], q.push_back(edges[i].to);
    }
    return h[D] != -1;
  }
  int dfs(int nod, int flow) {
    if (flow == 0 || nod == D) return flow;
    while (act[nod] != -1) {
      Edge& e = edges[act[nod]];
      int d;
      if (e.flow && h[e.to] == 1 + h[nod] &&
          (d = dfs(e.to, min(flow, e.flow))) != 0) {
        e.flow -= d;
        edges[act[nod] ^ 1].flow += d;
        return d;
      }
      act[nod] = edges[act[nod]].next;
    }
    return 0;
  }
  int GetFlow() {
    int f = 0;
    while (bfs()) {
      act = head;
      int d;
      while ((d = dfs(S, 1e9)) != 0) f += d;
    }
    return f;
  }
  Dinic(int dim = 0, int s = 0, int d = 0)
      : head(dim + 1, -1), h(dim + 1), S(s), D(d) {}
};
struct FlowWithMinRestrictions {
  struct Edge {
    int from, to, flowmin, flowmax, id;
  };
  vector<Edge> edges;
  int S, D, n;
  void AddEdge(int from, int to, int flowmin, int flowmax) {
    edges.push_back({from, to, flowmin, flowmax, 0});
  }
  vector<int> Solve(bool& feasible, int& flow) {
    feasible = 1;
    flow = 0;
    int news = n + 1, newd = n + 2;
    Dinic first_flow(n + 2, news, newd);
    first_flow.AddEdge(D, S, 1e9);
    int s_minime = 0;
    for (auto& i : edges) {
      if (i.flowmax < i.flowmin) {
        feasible = 0;
        return vector<int>();
      }
      s_minime += i.flowmin;
      i.id = first_flow.edges.size();
      first_flow.AddEdge(i.from, i.to, i.flowmax - i.flowmin);
      first_flow.AddEdge(news, i.to, i.flowmin);
      first_flow.AddEdge(i.from, newd, i.flowmin);
    }
    if (first_flow.GetFlow() != s_minime) {
      feasible = 0;
      return vector<int>();
    }
    Dinic curent_flow(n, S, D);
    for (auto& i : edges) {
      int dif = i.flowmax - i.flowmin;
      int passed = dif - first_flow.edges[i.id].flow;
      int nid = curent_flow.edges.size();
      curent_flow.AddEdge(i.from, i.to, first_flow.edges[i.id].flow, passed);
      i.id = nid;
    }
    curent_flow.GetFlow();
    vector<int> ans(edges.size());
    for (int i = 0; i < edges.size(); i++) {
      int cntflow = curent_flow.edges[edges[i].id ^ 1].flow + edges[i].flowmin;
      ans[i] = cntflow;
      if (edges[i].from == S) flow += cntflow;
      if (edges[i].to == S) flow -= cntflow;
    }
    return ans;
  }
  FlowWithMinRestrictions(int n = 0, int s = 0, int d = 0) : n(n), S(s), D(d) {}
};
namespace ProbD {
const int NMAX = 200010;
map<int, int> nrmx, nrmy;
FlowWithMinRestrictions flow;
pair<int, int> shields[NMAX];
int idshield[NMAX];
int n, S, D;
int difmax[NMAX];
int nr_on_poz[NMAX];
int cnt = 0;
void normalize() {
  for (int i = 0; i < n; i++)
    nrmx[shields[i].first] = nrmy[shields[i].second] = 0;
  for (auto& i : nrmx) i.second = cnt++;
  for (auto& i : nrmy) i.second = cnt++;
  S = cnt++;
  D = cnt;
  fill(difmax, difmax + cnt + 1, 1e9);
}
void solve() {
  int r, b;
  int nrc;
  cin >> n >> nrc >> r >> b;
  for (int i = 0; i < n; i++) cin >> shields[i].first >> shields[i].second;
  normalize();
  flow = FlowWithMinRestrictions(cnt, S, D);
  for (int i = 0; i < n; i++) {
    shields[i].first = nrmx[shields[i].first],
    shields[i].second = nrmy[shields[i].second];
    idshield[i] = flow.edges.size();
    nr_on_poz[shields[i].first]++, nr_on_poz[shields[i].second]++;
    flow.AddEdge(shields[i].first, shields[i].second, 0, 1);
  }
  while (nrc--) {
    int t, p, val;
    cin >> t >> p >> val;
    if (t == 1 && nrmx.find(p) != nrmx.end())
      difmax[nrmx[p]] = min(difmax[nrmx[p]], val);
    else if (t == 2 && nrmy.find(p) != nrmy.end())
      difmax[nrmy[p]] = min(difmax[nrmy[p]], val);
  }
  vector<pair<int, pair<int, int>>> verif;
  for (auto i : nrmx) {
    int nr = nr_on_poz[i.second];
    int dmax = difmax[i.second];
    int vmax = (dmax + nr) / 2;
    int vmin = max(0, (nr - dmax + 1) / 2);
    verif.push_back({(int)flow.edges.size(), {vmin, vmax}});
    flow.AddEdge(S, i.second, vmin, vmax);
  }
  for (auto i : nrmy) {
    int nr = nr_on_poz[i.second];
    int dmax = difmax[i.second];
    int vmax = (dmax + nr) / 2;
    int vmin = max(0, (nr - dmax + 1) / 2);
    verif.push_back({(int)flow.edges.size(), {vmin, vmax}});
    flow.AddEdge(i.second, D, vmin, vmax);
  }
  int f;
  bool posibil;
  auto ans = flow.Solve(posibil, f);
  if (!posibil) {
    cout << "-1\n";
    return;
  }
  for (auto i : verif)
    assert(ans[i.first] >= i.second.first && ans[i.first] <= i.second.second);
  cout << 1LL * f * min(r, b) + 1LL * (n - f) * max(r, b) << '\n';
  string s = "rb";
  if (r < b) s = "br";
  for (int i = 0; i < n; i++) cout << s[ans[idshield[i]]];
  cout << '\n';
}
}  // namespace ProbD
int main() {
  ios_base::sync_with_stdio(0);
  ProbD::solve();
  return 0;
  FILE* in = fopen("cuplaj.in", "r");
  int n, m;
  fscanf(in, "%d%d", &n, &m);
  FlowWithMinRestrictions flow(n, 1, n);
  while (m--) {
    int a, b, c, d;
    fscanf(in, "%d%d%d%d", &a, &b, &c, &d);
    flow.AddEdge(a, b, c, d);
  }
  bool feasible;
  int f;
  auto ans = flow.Solve(feasible, f);
  ofstream out("flux.out");
  out << feasible << '\n' << f << '\n';
  for (auto i : ans) out << i << ' ';
  return 0;
}