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 = 100005;
bool debug_flag = false;
int n, m, r, b, row_lim[2 * Maxn], col_lim[2 * Maxn];
;
vector<int> row, col, Row[2 * Maxn], Col[2 * Maxn];
struct node {
  int x, y;
} w[Maxn];
struct limit {
  int type, l, d;
} q[Maxn];
namespace dinic {
const int MAXN = 3 * Maxn, MAXM = 25 * Maxn;
int h[MAXN], cur[MAXN], dis[MAXN], d[MAXN], S, T, cnt;
struct node {
  int to, next;
  long long v;
  int pair;
} e[2 * MAXM];
void AddEdge(int x, int y, long long v, int pair) {
  e[cnt] = (node){y, h[x], v, pair};
  h[x] = cnt;
}
void AddEdge(int x, int y, long long v) {
  AddEdge(x, y, v, ++cnt + 1);
  AddEdge(y, x, 0, ++cnt - 1);
}
bool bfs() {
  static bool vis[MAXN];
  memset(vis, 0, sizeof(vis));
  memset(dis, 0x3f, sizeof(dis));
  vis[S] = true;
  dis[S] = 0;
  queue<int> Q;
  Q.push(S);
  while (Q.size()) {
    int x = Q.front();
    Q.pop();
    for (int p = h[x]; p; p = e[p].next) {
      int y = e[p].to;
      if (e[p].v && !vis[y]) {
        vis[y] = true;
        dis[y] = dis[x] + 1;
        Q.push(y);
      }
    }
  }
  return vis[T];
}
long long dfs(int x, long long Maxflow) {
  if (!Maxflow || x == T) return Maxflow;
  long long flow = 0;
  for (int& p = cur[x]; p; p = e[p].next) {
    int y = e[p].to, ret;
    if (dis[y] != dis[x] + 1) continue;
    ret = dfs(y, min(Maxflow, e[p].v));
    e[p].v -= ret;
    e[e[p].pair].v += ret;
    flow += ret;
    Maxflow -= ret;
    if (!Maxflow) break;
  }
  if (!flow) dis[x] = 0;
  return flow;
}
long long dinic(int s, int t) {
  S = s, T = t;
  long long ans = 0;
  while (bfs()) {
    memcpy(cur, h, sizeof(h));
    ans += dfs(S, 1e9);
  }
  return ans;
}
long long solve(int s, int t, vector<int> v,
                vector<tuple<int, int, int, int>>& edge) {
  int S = 0, T;
  long long sum = 0;
  for (int i : v) S = max(i, S);
  T = (++S) + 1;
  for (auto& e : edge) {
    int src, dst, min, max;
    tie(src, dst, min, max) = e;
    if (min > max) return -1;
    d[src] -= min;
    d[dst] += min;
    AddEdge(src, dst, max - min);
  }
  for (int i : v)
    if (d[i] > 0)
      AddEdge(S, i, d[i]), sum += d[i];
    else if (d[i] < 0)
      AddEdge(i, T, -d[i]);
  AddEdge(t, s, 1e9);
  long long flow = dinic(S, T);
  h[s] = e[h[s]].next;
  h[t] = e[h[t]].next;
  if (flow != sum) return -1;
  return dinic(s, t) + e[cnt].v;
}
void print(int n, int l, int r, bool rev) {
  for (int i = 1; i <= n; i++) {
    bool succ = false;
    for (int p = h[i]; p && !succ; p = e[p].next) {
      int y = e[p].to;
      if (l <= y && y <= r && !e[p].v) succ = true, cout << (rev ? 'b' : 'r');
    }
    if (!succ) cout << (rev ? 'r' : 'b');
  }
  cout << "\n";
}
}  // namespace dinic
inline int Getint() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int main() {
  bool rev = false;
  n = Getint(), m = Getint(), r = Getint(), b = Getint();
  debug_flag = r == 341412296 && b == 266451126;
  if (r > b) swap(r, b), rev = true;
  for (int i = 1; i <= n; i++) w[i].x = Getint(), w[i].y = Getint();
  for (int i = 1; i <= m; i++)
    q[i].type = Getint(), q[i].l = Getint(), q[i].d = Getint();
  for (int i = 1; i <= n; i++) row.push_back(w[i].x), col.push_back(w[i].y);
  sort(row.begin(), row.end());
  sort(col.begin(), col.end());
  row.erase(unique(row.begin(), row.end()), row.end());
  col.erase(unique(col.begin(), col.end()), col.end());
  for (int i = 1; i <= n; i++)
    w[i].x = lower_bound(row.begin(), row.end(), w[i].x) - row.begin() + 1;
  for (int i = 1; i <= n; i++)
    w[i].y = lower_bound(col.begin(), col.end(), w[i].y) - col.begin() + 1;
  for (int i = 1; i <= n; i++) Row[w[i].x].push_back(i);
  for (int i = 1; i <= n; i++) Col[w[i].y].push_back(i);
  for (size_t i = 1; i <= row.size(); i++) row_lim[i] = n;
  for (size_t i = 1; i <= col.size(); i++) col_lim[i] = n;
  for (int i = 1; i <= m; i++) {
    auto& vec = q[i].type == 1 ? row : col;
    int* lim = q[i].type == 1 ? row_lim : col_lim;
    if (!binary_search(vec.begin(), vec.end(), q[i].l)) continue;
    q[i].l = lower_bound(vec.begin(), vec.end(), q[i].l) - vec.begin() + 1;
    lim[q[i].l] = min(lim[q[i].l], q[i].d);
  }
  int S = row.size() + col.size() + n + 1, T = S + 1, id = n;
  vector<int> v;
  vector<tuple<int, int, int, int>> edge;
  for (size_t i = 1; i <= row.size(); i++) {
    edge.emplace_back(S, ++id,
                      max(0, (int(Row[i].size()) - row_lim[i] + 1) / 2),
                      (int(Row[i].size()) + row_lim[i]) / 2);
    for (auto j : Row[i]) edge.emplace_back(id, j, 0, 1);
  }
  for (size_t i = 1; i <= col.size(); i++) {
    edge.emplace_back(++id, T,
                      max(0, (int(Col[i].size()) - col_lim[i] + 1) / 2),
                      (int(Col[i].size()) + col_lim[i]) / 2);
    for (auto j : Col[i]) edge.emplace_back(j, id, 0, 1);
  }
  for (int i = 1; i <= T; i++) v.push_back(i);
  long long ans = dinic::solve(S, T, v, edge);
  if (ans == -1)
    puts("-1");
  else {
    ans = ans * r + (n - ans) * b;
    cout << ans << "\n";
    dinic::print(n, n + row.size() + 1, S - 1, rev);
  }
  return 0;
}