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 N = 4e5 + 9;
const long long mod = 998244353;
const int Inf = 1e9;
struct edge {
  int u, c, nxt;
} e[2000000];
int vis[N];
int head[N], s, t, ss, tt, cnt;
void add(int u, int v, int c) {
  e[cnt] = (edge){v, c, head[u]}, head[u] = cnt++;
  e[cnt] = (edge){u, 0, head[v]}, head[v] = cnt++;
}
bool bfs(int s, int t) {
  memset(vis, -1, sizeof vis);
  queue<int> q;
  q.push(s);
  vis[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; ~i; i = e[i].nxt) {
      int w = e[i].u;
      if (vis[w] == -1 && e[i].c > 0) {
        vis[w] = vis[u] + 1;
        q.push(w);
      }
    }
  }
  return vis[t] != -1;
}
int findf(int x, int t, int flow) {
  if (x == t) return flow;
  int res = 0;
  for (int i = head[x]; ~i; i = e[i].nxt) {
    int w = e[i].u;
    if (vis[w] == vis[x] + 1 && e[i].c > 0) {
      int ff = findf(w, t, min(e[i].c, flow));
      if (!ff) continue;
      e[i].c -= ff;
      e[i ^ 1].c += ff;
      res += ff;
      flow -= ff;
      if (!flow) break;
    }
  }
  if (!res) vis[x] = -1;
  return res;
}
int ans;
void dinic(int s, int t) {
  while (bfs(s, t)) ans += findf(s, t, Inf);
}
vector<int> px, py;
int x[N], y[N], op[N], l[N], d[N], mini[N], sum[N], dd[N];
void addlim(int u, int v, int L, int R) {
  if (L > R) {
    puts("-1");
    exit(0);
  }
  dd[u] -= L;
  dd[v] += L;
  add(u, v, R - L);
}
int main() {
  tt = N - 1, ss = tt - 1, t = ss - 1, s = t - 1;
  memset(head, -1, sizeof head);
  int n, m, r, b;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &b);
  int flag = 0;
  if (r > b) swap(r, b), flag = 1;
  for (int i = (0); i < (n); ++i)
    scanf("%d%d", &x[i], &y[i]), px.push_back(x[i]), py.push_back(y[i]);
  for (int i = (0); i < (m); ++i) {
    scanf("%d%d%d", &op[i], &l[i], &d[i]);
    if (op[i] == 1) {
      px.push_back(l[i]);
    } else {
      py.push_back(l[i]);
    }
  }
  sort(px.begin(), px.end());
  sort(py.begin(), py.end());
  px.resize(unique(px.begin(), px.end()) - px.begin());
  py.resize(unique(py.begin(), py.end()) - py.begin());
  for (int i = (0); i < (n); ++i)
    x[i] = lower_bound(px.begin(), px.end(), x[i]) - px.begin(), sum[x[i]]++,
    y[i] = lower_bound(py.begin(), py.end(), y[i]) - py.begin(),
    sum[y[i] + px.size()]++;
  for (int i = (0); i < (m); ++i) {
    if (op[i] == 1) {
      l[i] = lower_bound(px.begin(), px.end(), l[i]) - px.begin();
    } else {
      l[i] = lower_bound(py.begin(), py.end(), l[i]) - py.begin();
    }
  }
  for (int i = (0); i < (px.size() + py.size()); ++i) mini[i] = sum[i];
  for (int i = (0); i < (m); ++i) {
    if (op[i] == 1) {
      mini[l[i]] = min(mini[l[i]], d[i]);
    } else {
      mini[l[i] + px.size()] = min(mini[l[i] + px.size()], d[i]);
    }
  }
  for (int i = (0); i < (n); ++i) {
    add(x[i], y[i] + px.size(), 1);
  }
  for (int i = (0); i < (px.size()); ++i) {
    addlim(ss, i, sum[i] - mini[i] + 1 >> 1, sum[i] + mini[i] >> 1);
  }
  for (int i = (px.size()); i < (px.size() + py.size()); ++i) {
    addlim(i, tt, sum[i] - mini[i] + 1 >> 1, sum[i] + mini[i] >> 1);
  }
  add(tt, ss, Inf);
  int tot = 0;
  for (int i = (0); i < (N); ++i) {
    if (dd[i] > 0) {
      tot += dd[i];
      add(s, i, dd[i]);
    } else if (dd[i] < 0) {
      add(i, t, -dd[i]);
    }
  }
  dinic(s, t);
  if (ans ^ tot) {
    puts("-1");
    return 0;
  }
  ans = 0;
  dinic(ss, tt);
  printf("%lld\n", 1ll * ans * r + 1ll * (n - ans) * b);
  for (int i = (0); i < (n); ++i) {
    if (e[i << 1].c ^ flag)
      printf("b");
    else
      printf("r");
  }
}