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;
namespace Dango {
const int MAXN = 200005, INF = 0x3f3f3f3f;
namespace Dinic {
struct Edge {
  int from, to, cap, flow;
};
vector<Edge> edges;
vector<int> g[MAXN << 1];
int s, t;
int d[MAXN << 1], dur[MAXN << 1];
void add(int u, int v, int cap) {
  edges.push_back((Edge){u, v, cap, 0});
  edges.push_back((Edge){v, u, 0, 0});
  int s = edges.size();
  g[u].push_back(s - 2);
  g[v].push_back(s - 1);
}
bool bfs() {
  queue<int> q;
  static bool vis[MAXN];
  memset(vis, 0, sizeof(vis));
  d[s] = 1;
  vis[s] = true;
  q.push(s);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < g[x].size(); i++) {
      Edge &e = edges[g[x][i]];
      if (!vis[e.to] && e.cap > e.flow) {
        vis[e.to] = true;
        d[e.to] = d[x] + 1;
        q.push(e.to);
      }
    }
  }
  return vis[t];
}
int dfs(int x, int a) {
  if (x == t || !a) return a;
  int flow = 0, f;
  for (int &i = dur[x]; i < g[x].size(); i++) {
    Edge &e = edges[g[x][i]];
    if (d[e.to] == d[x] + 1 && (f = dfs(e.to, min(a, e.cap - e.flow))) > 0) {
      e.flow += f;
      edges[g[x][i] ^ 1].flow -= f;
      flow += f;
      a -= f;
      if (!a) break;
    }
  }
  return flow;
}
int work(int u, int v) {
  int res = 0;
  s = u;
  t = v;
  while (bfs()) {
    memset(dur, 0, sizeof(dur));
    res += dfs(s, INF);
  }
  return res;
}
}  // namespace Dinic
struct shell {
  int x, y;
} p[MAXN];
int n, m, r, b;
int x[MAXN], y[MAXN];
int sx[MAXN], sy[MAXN];
int dx[MAXN], dy[MAXN];
int val[MAXN << 1];
int S, T;
long long tot, res, ans;
bool tag;
int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    f |= (ch == '-');
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f ? -x : x;
}
void init() {
  for (int i = 1; i <= n; i++) {
    x[i] = p[i].x;
    y[i] = p[i].y;
  }
  sort(x + 1, x + n + 1);
  sort(y + 1, y + n + 1);
  x[0] = unique(x + 1, x + n + 1) - x - 1;
  y[0] = unique(y + 1, y + n + 1) - y - 1;
  for (int i = 1; i <= n; i++) {
    p[i].x = lower_bound(x + 1, x + x[0] + 1, p[i].x) - x;
    p[i].y = lower_bound(y + 1, y + y[0] + 1, p[i].y) - y;
    sx[p[i].x]++;
    sy[p[i].y]++;
    Dinic::add(p[i].x + 1, p[i].y + x[0] + 1, 1);
  }
}
int work() {
  n = read();
  m = read();
  r = read();
  b = read();
  if (r > b) {
    swap(r, b);
    tag = true;
  }
  for (int i = 1; i <= n; i++) {
    p[i].x = read();
    p[i].y = read();
  }
  init();
  for (int i = 1; i <= x[0]; i++) dx[i] = sx[i];
  for (int i = 1; i <= y[0]; i++) dy[i] = sy[i];
  for (int i = 1; i <= m; i++) {
    int t = read(), l = read(), d = read();
    if (t == 1) {
      int pos = lower_bound(x + 1, x + x[0] + 1, l) - x;
      if (x[pos] != l) continue;
      dx[pos] = min(dx[pos], d);
    }
    if (t == 2) {
      int pos = lower_bound(y + 1, y + y[0] + 1, l) - y;
      if (y[pos] != l) continue;
      dy[pos] = min(dy[pos], d);
    }
  }
  for (int i = 1; i <= x[0]; i++) {
    int up = (sx[i] + dx[i]) / 2, down = sx[i] - up;
    if (up < down) {
      printf("-1");
      return 0;
    }
    Dinic::add(1, i + 1, up - down);
    val[1] -= down;
    val[i + 1] += down;
  }
  for (int i = 1; i <= y[0]; i++) {
    int up = (sy[i] + dy[i]) / 2, down = sy[i] - up;
    if (up < down) {
      printf("-1");
      return 0;
    }
    Dinic::add(i + x[0] + 1, x[0] + y[0] + 2, up - down);
    val[i + x[0] + 1] -= down;
    val[x[0] + y[0] + 2] += down;
  }
  Dinic::add(x[0] + y[0] + 2, 1, INF);
  T = x[0] + y[0] + 3;
  for (int i = 1; i < T; i++) {
    if (val[i] > 0) {
      Dinic::add(S, i, val[i]);
      tot += val[i];
    }
    if (val[i] < 0) Dinic::add(i, T, -val[i]);
  }
  tot -= Dinic::work(S, T);
  if (tot) {
    printf("-1");
    return 0;
  }
  res = Dinic::work(1, T - 1);
  ans = res * r + (n - res) * b;
  printf("%lld\n", ans);
  for (int i = 0; i < n; i++)
    (Dinic::edges[i * 2].flow ^ tag) ? printf("r") : printf("b");
  return 0;
}
}  // namespace Dango
int main() { return Dango::work(); }