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 MAXN = 220000;
const int INF = 1E9;
const long long LINF = 1E18;
namespace MF {
struct Edge {
  int from, to;
  long long cap, flow;
  Edge(int u, int v, long long c, long long f)
      : from(u), to(v), cap(c), flow(f) {}
};
int n, s, t;
long long flow;
vector<Edge> edges;
vector<int> g[MAXN];
int h[MAXN], cur[MAXN];
void init(int v, int a, int b) {
  n = v, s = a, t = b, flow = 0;
  edges.clear();
  for (int i = 1; i <= n; i++) g[i].clear();
}
int addEdge(int from, int to, long long cap) {
  edges.push_back(Edge(from, to, cap, 0));
  edges.push_back(Edge(to, from, 0, 0));
  g[from].push_back(edges.size() - 2);
  g[to].push_back(edges.size() - 1);
  return edges.size() - 2;
}
bool bfs() {
  queue<int> q;
  for (int i = 1; i <= n; i++) cur[i] = h[i] = 0;
  h[s] = 1, q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); i++) {
      Edge e = edges[g[u][i]];
      if (e.cap > e.flow && !h[e.to]) h[e.to] = h[u] + 1, q.push(e.to);
    }
  }
  return h[t];
}
long long dfs(int u, long long f) {
  if (u == t) return f;
  for (int &i = cur[u]; i < g[u].size(); i++) {
    Edge &e = edges[g[u][i]];
    if (e.cap > e.flow && h[e.to] == h[u] + 1) {
      long long d = dfs(e.to, min(f, e.cap - e.flow));
      if (d > 0) {
        e.flow += d;
        edges[g[u][i] ^ 1].flow -= d;
        return d;
      }
    }
  }
  return 0;
}
void Dinic() {
  while (bfs())
    while (long long f = dfs(s, LINF)) flow += f;
}
}  // namespace MF
namespace MFC {
int n, s, t;
long long d[MAXN];
void init(int v) {
  n = v, s = v + 1, t = v + 2;
  MF::init(n + 2, s, t);
  for (int i = 1; i <= n; i++) d[i] = 0;
}
int addEdge(int from, int to, long long low, long long up) {
  if (low > up) puts("-1"), exit(0);
  d[from] -= low, d[to] += low;
  return MF::addEdge(from, to, up - low);
}
bool getany() {
  long long sum = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] > 0)
      MF::addEdge(s, i, d[i]), sum += d[i];
    else if (d[i] < 0)
      MF::addEdge(i, t, -d[i]);
  MF::Dinic();
  return MF::flow == sum;
}
void getmax(int a, int b) {
  for (int i = 0; i < MF::edges.size(); i++) {
    MF::Edge &e = MF::edges[i];
    if (e.from == b && e.to == a) {
      MF::flow = e.flow;
      e.cap = e.flow = MF::edges[i ^ 1].flow = 0;
    } else if (e.from == s || e.to == t)
      e.cap = e.flow = MF::edges[i ^ 1].flow = 0;
  }
  MF::s = a, MF::t = b, MF::Dinic();
}
}  // namespace MFC
int x[MAXN], y[MAXN];
int vx[MAXN], vy[MAXN], p, q;
int cx[MAXN], cy[MAXN];
int dx[MAXN], dy[MAXN];
int id[MAXN];
inline int posx(int k) { return lower_bound(vx + 1, vx + p + 1, k) - vx; }
inline int posy(int k) { return lower_bound(vy + 1, vy + q + 1, k) - vy; }
int main() {
  int n, m, r, b;
  scanf("%d%d%d%d", &n, &m, &r, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    vx[++p] = x[i], vy[++q] = y[i];
  }
  sort(vx + 1, vx + p + 1), p = unique(vx + 1, vx + p + 1) - vx - 1;
  sort(vy + 1, vy + q + 1), q = unique(vy + 1, vy + q + 1) - vy - 1;
  for (int i = 1; i <= p; i++) cx[i] = 0, dx[i] = INF;
  for (int i = 1; i <= q; i++) cy[i] = 0, dy[i] = INF;
  for (int i = 1; i <= m; i++) {
    int t, l, k;
    scanf("%d%d%d", &t, &l, &k);
    if (t == 1) {
      int u = posx(l);
      if (vx[u] == l) dx[u] = min(dx[u], k);
    } else {
      int u = posy(l);
      if (vy[u] == l) dy[u] = min(dy[u], k);
    }
  }
  MFC::init(p + q + 2);
  int s = p + q + 1, t = p + q + 2;
  MFC::addEdge(t, s, 0, INF);
  for (int i = 1; i <= n; i++) {
    int u = posx(x[i]), v = posy(y[i]);
    id[i] = MFC::addEdge(u, v + p, 0, 1);
    cx[u]++, cy[v]++;
  }
  for (int i = 1; i <= p; i++)
    MFC::addEdge(s, i, (cx[i] - dx[i] + 1) / 2, (cx[i] + dx[i]) / 2);
  for (int i = 1; i <= q; i++)
    MFC::addEdge(i + p, t, (cy[i] - dy[i] + 1) / 2, (cy[i] + dy[i]) / 2);
  if (!MFC::getany())
    puts("-1");
  else {
    MFC::getmax(s, t);
    long long ans = 0;
    string ret;
    for (int i = 1; i <= n; i++) {
      bool t = MF::edges[id[i]].flow ^ (b < r);
      if (t)
        ans += r, ret += 'r';
      else
        ans += b, ret += 'b';
    }
    cout << ans << endl << ret << endl;
  }
  return 0;
}