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;
template <typename T>
T getint() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') p = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * p;
}
template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {
  if (x < y) return x = y, true;
  return false;
}
const int maxn = (int)1e6 + 100;
const int inf = (int)1e9 + 5;
const long long llinf = (long long)1e18 - 1;
const long double pi = acos(-1.0);
namespace flow {
const int maxn = 2e5 + 100;
int S, T;
int realS, realT;
int capS[maxn];
int capT[maxn];
struct edge {
  int to, cap, flow;
  edge() {}
  edge(int to, int cap) : to(to), cap(cap), flow(0) {}
};
int n;
int minflow = 0;
vector<int> g[maxn];
vector<edge> edges;
int c = 0;
void init(int n) {
  flow::n = n;
  S = n;
  T = n + 1;
  realS = n - 1;
  realT = n - 2;
  c = 0;
  for (int i = (0); i < (n + 2); i++) g[i].clear();
  edges.clear();
}
void addrealedge(int x, int y, int cap) {
  if (cap == 0) return;
  g[x].push_back(c++);
  edges.push_back(edge(y, cap));
  g[y].push_back(c++);
  edges.push_back(edge(x, 0));
}
void addedge(int x, int y, int L, int R) {
  if (L > R) {
    cout << -1 << endl;
    exit(0);
  }
  minflow += L;
  capS[y] += L;
  capT[x] += L;
  addrealedge(x, y, R - L);
}
int qu[maxn];
int lvl[maxn];
int qs, qf;
bool bfs(int S, int T) {
  for (int i = (0); i < (n + 2); i++) lvl[i] = -1;
  lvl[T] = -1;
  qs = qf = 0;
  lvl[S] = 0;
  qu[qf++] = S;
  while (qs < qf && lvl[T] == -1) {
    int v = qu[qs++];
    for (int e : g[v]) {
      if (edges[e].cap != edges[e].flow && lvl[edges[e].to] == -1) {
        lvl[edges[e].to] = lvl[v] + 1;
        qu[qf++] = edges[e].to;
      }
    }
  }
  return lvl[T] != -1;
}
int ptr[maxn];
int dfs(int v, int flow) {
  if (flow == 0 || realT == v) return flow;
  for (int &i = ptr[v]; i < (int)g[v].size(); ++i) {
    int e = g[v][i];
    if (lvl[v] != lvl[edges[e].to] - 1) continue;
    int val = dfs(edges[e].to, min(flow, edges[e].cap - edges[e].flow));
    if (val == 0) continue;
    edges[e].flow += val;
    edges[e ^ 1].flow -= val;
    return val;
  }
  return 0;
}
void doit() {
  for (int i = (0); i < (n + 2); i++) {
    if (i == realS || i == realT) continue;
    addrealedge(realS, i, capS[i]);
    addrealedge(i, realT, capT[i]);
  }
}
int maxflow() {
  for (auto &e : edges) e.flow = 0;
  int ret = 0;
  while (bfs(realS, realT)) {
    for (int i = (0); i < (n + 2); i++) ptr[i] = 0;
    while (true) {
      int x = dfs(realS, inf);
      if (x == 0) break;
      ret += x;
    }
  }
  return ret;
}
}  // namespace flow
bool ok(int x) {
  flow::edges[(int)flow::edges.size() - 2].cap = x;
  return (flow::maxflow() >= flow::minflow);
}
int main() {
  int n = getint<int>();
  int m = getint<int>();
  flow::init(10 + 2 * n);
  vector<int> x, y;
  vector<int> xx(n), yy(n);
  int r = getint<int>();
  int b = getint<int>();
  for (int i = (0); i < (n); i++) {
    xx[i] = getint<int>();
    yy[i] = getint<int>();
    x.push_back(xx[i]);
    y.push_back(yy[i]);
  }
  sort((x).begin(), (x).end());
  x.erase(unique((x).begin(), (x).end()), x.end());
  sort((y).begin(), (y).end());
  y.erase(unique((y).begin(), (y).end()), y.end());
  vector<int> degx(n), degy(n);
  for (int i = (0); i < (n); i++) {
    xx[i] = lower_bound((x).begin(), (x).end(), xx[i]) - x.begin();
    yy[i] = lower_bound((y).begin(), (y).end(), yy[i]) - y.begin();
    degx[xx[i]]++;
    degy[yy[i]]++;
    flow::addedge(xx[i], n + yy[i], 0, 1);
  }
  vector<int> mx((int)x.size(), n);
  vector<int> my((int)y.size(), n);
  while (m--) {
    int t, l, d;
    t = getint<int>();
    l = getint<int>();
    d = getint<int>();
    if (t == 1) {
      if (!binary_search((x).begin(), (x).end(), l)) continue;
      umin(mx[lower_bound((x).begin(), (x).end(), l) - x.begin()], d);
    } else {
      if (!binary_search((y).begin(), (y).end(), l)) continue;
      umin(my[lower_bound((y).begin(), (y).end(), l) - y.begin()], d);
    }
  }
  for (int i = (0); i < ((int)x.size()); i++) {
    int L = max(0, (degx[i] - mx[i] + 1) / 2);
    int R = min(degx[i], (degx[i] + mx[i]) / 2);
    flow::addedge(flow::S, i, L, R);
  }
  for (int i = (0); i < ((int)y.size()); i++) {
    int L = max(0, (degy[i] - my[i] + 1) / 2);
    int R = min(degy[i], (degy[i] + my[i]) / 2);
    flow::addedge(n + i, flow::T, L, R);
  }
  flow::doit();
  flow::addrealedge(flow::T, flow::S, inf);
  if (flow::maxflow() < flow::minflow) {
    cout << -1 << endl;
    return 0;
  }
  int lf = 0, rg = n + 2;
  while (rg - lf > 1) {
    int m = (lf + rg) / 2;
    if (ok(m)) {
      rg = m;
    } else
      lf = m;
  }
  flow::edges[(int)flow::edges.size() - 2].cap = rg;
  flow::maxflow();
  char R = 'r', B = 'b';
  if (r < b) swap(r, b), swap(R, B);
  long long res = 0;
  for (int i = (0); i < (n); i++) {
    if (flow::edges[2 * i].flow == 1)
      res += r;
    else
      res += b;
  }
  printf("%I64d\n", res);
  for (int i = (0); i < (n); i++) {
    if (flow::edges[2 * i].flow == 1)
      putchar(R);
    else
      putchar(B);
  }
  return 0;
}