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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
template <typename T>
void ckmin(T& a, const T& b) {
  a = min(a, b);
}
template <typename T>
void ckmax(T& a, const T& b) {
  a = max(a, b);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace __input {
template <class T1, class T2>
void re(pair<T1, T2>& p);
template <class T>
void re(vector<T>& a);
template <class T, size_t SZ>
void re(array<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& x) {
  string t;
  re(t);
  x = stod(t);
}
template <class Arg, class... Args>
void re(Arg& first, Args&... rest) {
  re(first);
  re(rest...);
}
template <class T1, class T2>
void re(pair<T1, T2>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& a) {
  for (int i = 0; i < (int((a).size())); i++) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ>& a) {
  for (int i = 0; i < (SZ); i++) re(a[i]);
}
}  // namespace __input
using namespace __input;
namespace __output {
template <class T1, class T2>
void pr(const pair<T1, T2>& x);
template <class T, size_t SZ>
void pr(const array<T, SZ>& x);
template <class T>
void pr(const vector<T>& x);
template <class T>
void pr(const set<T>& x);
template <class T1, class T2>
void pr(const map<T1, T2>& x);
template <class T>
void pr(const T& x) {
  cout << x;
}
template <class Arg, class... Args>
void pr(const Arg& first, const Args&... rest) {
  pr(first);
  pr(rest...);
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T, bool pretty = true>
void prContain(const T& x) {
  if (pretty) pr("{");
  bool fst = 1;
  for (const auto& a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
  if (pretty) pr("}");
}
template <class T>
void pc(const T& x) {
  prContain<T, false>(x);
  pr("\n");
}
template <class T, size_t SZ>
void pr(const array<T, SZ>& x) {
  prContain(x);
}
template <class T>
void pr(const vector<T>& x) {
  prContain(x);
}
template <class T>
void pr(const set<T>& x) {
  prContain(x);
}
template <class T1, class T2>
void pr(const map<T1, T2>& x) {
  prContain(x);
}
void ps() { pr("\n"); }
template <class Arg>
void ps(const Arg& first) {
  pr(first);
  ps();
}
template <class Arg, class... Args>
void ps(const Arg& first, const Args&... rest) {
  pr(first, " ");
  ps(rest...);
}
}  // namespace __output
using namespace __output;
namespace __algorithm {
template <typename T>
void dedup(vector<T>& v) {
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
}
template <typename T>
typename vector<T>::iterator find(vector<T>& v, const T& x) {
  auto it = lower_bound((v).begin(), (v).end(), x);
  return it != v.end() && *it == x ? it : v.end();
}
template <typename T>
size_t index(vector<T>& v, const T& x) {
  auto it = find(v, x);
  assert(it != v.end() && *it == x);
  return it - v.begin();
}
template <typename C, typename T>
vector<T> prefixes(const C& v, T zero) {
  vector<T> res(int((v).size()) + 1, zero);
  for (int i = 0; i < (int((v).size())); i++) res[i + 1] = res[i] + v[i];
  return res;
}
template <typename C, typename T>
vector<T> suffixes(const C& v, T zero) {
  vector<T> res(int((v).size()) + 1, zero);
  for (int i = (int((v).size())) - 1; i >= 0; i--) res[i] = v[i] + res[i + 1];
  return res;
}
}  // namespace __algorithm
using namespace __algorithm;
struct monostate {
  friend istream& operator>>(istream& is,
                             const __attribute__((unused)) monostate& ms) {
    return is;
  }
  friend ostream& operator<<(ostream& os,
                             const __attribute__((unused)) monostate& ms) {
    return os;
  }
} ms;
template <typename W = monostate>
struct wedge {
  int u, v, i;
  W w;
  wedge<W>(int _u = -1, int _v = -1, int _i = -1) : u(_u), v(_v), i(_i) {}
  int operator[](int loc) const { return u ^ v ^ loc; }
  friend void re(wedge& e) {
    re(e.u, e.v, e.w);
    --e.u, --e.v;
  }
  friend void pr(const wedge& e) { pr(e.u, "<-", e.w, "->", e.v); }
};
namespace __io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(15);
  if (int((second).size())) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace __io
using namespace __io;
template <typename F>
struct dinic {
  static const F inf = numeric_limits<F>::max();
  int V;
  vvi adj;
  vi dest;
  vector<F> cap;
  dinic(int V = 0) : V(V) { adj.resize(V); }
  void __arc(int u, int v, F c) {
    adj[u].push_back(dest.size());
    dest.push_back(v);
    cap.push_back(c);
  }
  void arc(int u, int v, F c) {
    __arc(u, v, c);
    __arc(v, u, F(0));
  }
  bool bfs(int second, int t, vi& level, vector<F>& flow) const {
    level = vi(V, -1);
    level[second] = 0;
    for (queue<int> q({second}); !q.empty(); q.pop()) {
      int u = q.front();
      for (int e : adj[u]) {
        if (level[dest[e]] == -1 && flow[e] < cap[e]) {
          level[dest[e]] = level[u] + 1;
          q.push(dest[e]);
        }
      }
    }
    return level[t] != -1;
  }
  F augment(int second, int t, vi& level, vector<F>& flow, vi& inx,
            F cur) const {
    if (second == t) return cur;
    for (int e; inx[second] < adj[second].size(); inx[second]++) {
      e = adj[second][inx[second]];
      if (level[dest[e]] != level[second] + 1) continue;
      if (flow[e] == cap[e]) continue;
      F incr =
          augment(dest[e], t, level, flow, inx, min(cur, cap[e] - flow[e]));
      if (incr > F(0)) {
        flow[e] += incr;
        flow[e ^ 1] -= incr;
        return incr;
      }
    }
    return F(0);
  }
  tuple<F, vector<F>> max_flow(int second, int t, vector<F> flow = {}) const {
    assert(second != t);
    F res(0);
    if (flow.empty()) flow.resize(int((cap).size()));
    for (vi level; bfs(second, t, level, flow);) {
      for (vi inx(V, 0); F incr = augment(second, t, level, flow, inx, inf);)
        res += incr;
    }
    return make_tuple(res, flow);
  }
};
pii bound(int V, int D) {
  ckmin(D, V);
  int lo = (V - D + 1) / 2;
  if (lo > V - lo) {
    ps(-1);
    exit(0);
  }
  return {lo, V - lo};
}
int main() {
  setIO();
  int N, M, R, B;
  re(N, M, R, B);
  vi x(N), y(N);
  for (int i = 0; i < (N); i++) re(x[i], y[i]);
  vi xc = x;
  dedup(xc);
  vi yc = y;
  dedup(yc);
  vi xd(int((xc).size()), N), yd(int((yc).size()), N);
  for (int j = 0; j < (M); j++) {
    int t, l, d;
    re(t, l, d);
    if (t == 1) {
      auto it = lower_bound((xc).begin(), (xc).end(), l);
      if (it != xc.end() && *it == l) ckmin(xd[it - xc.begin()], d);
    } else {
      auto it = lower_bound((yc).begin(), (yc).end(), l);
      if (it != yc.end() && *it == l) ckmin(yd[it - yc.begin()], d);
    }
  }
  vi xe(int((xc).size())), ye(int((yc).size()));
  for (int i = 0; i < (N); i++) {
    xe[index(xc, x[i])]++;
    ye[index(yc, y[i])]++;
  }
  int tot_min = 0;
  dinic<int> g(4 + int((xc).size()) + int((yc).size()));
  for (int i = 0; i < (int((xc).size())); i++) {
    pii xb = bound(xe[i], xd[i]);
    g.arc(2, 4 + i, xb.second - xb.first);
    g.arc(0, 4 + i, xb.first);
    g.arc(2, 1, xb.first);
    tot_min += xb.first;
  }
  for (int j = 0; j < (int((yc).size())); j++) {
    pii yb = bound(ye[j], yd[j]);
    g.arc(4 + int((xc).size()) + j, 3, yb.second - yb.first);
    g.arc(0, 3, yb.first);
    g.arc(4 + int((xc).size()) + j, 1, yb.first);
    tot_min += yb.first;
  }
  g.arc(3, 2, INT_MAX);
  vi eid(N);
  for (int i = 0; i < (N); i++) {
    eid[i] = int((g.cap).size());
    g.arc(4 + index(xc, x[i]), 4 + int((xc).size()) + index(yc, y[i]), 1);
  }
  int fv;
  vi fl;
  tie(fv, fl) = g.max_flow(0, 1);
  if (fv != tot_min) {
    ps(-1);
    return 0;
  }
  tie(fv, fl) = g.max_flow(2, 3, fl);
  ps(ll(fv) * min(R, B) + ll(N - fv) * max(R, B));
  for (int i = 0; i < (N); i++) pr(fl[eid[i]] > 0 ^ R > B ? 'r' : 'b');
  ps();
  return 0;
}