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 = 100010;
class edge {
 public:
  int e, nxt, cap;
  edge() {}
  edge(int e1, int nxt1, int cap1) { e = e1, nxt = nxt1, cap = cap1; }
};
class graph {
 public:
  int S, T;
  void set(int s, int t) {
    S = s;
    T = t;
  }
  edge g[2000010];
  int ecnt, head[N << 1], dep[N << 1], cur[N << 1];
  void init() {
    memset(head, 255, sizeof(head));
    ecnt = 0;
  }
  int addedge(int s, int e, int cap) {
    g[ecnt] = edge(e, head[s], cap), head[s] = ecnt++;
    g[ecnt] = edge(s, head[e], 0), head[e] = ecnt++;
    return ecnt - 2;
  }
  bool bfs() {
    memset(dep, 255, sizeof(dep));
    queue<int> q;
    q.push(S);
    dep[S] = 0;
    while (!q.empty()) {
      int fr = q.front();
      q.pop();
      for (int i = head[fr]; i != -1; i = g[i].nxt) {
        if (g[i].cap && dep[g[i].e] == -1) {
          dep[g[i].e] = dep[fr] + 1;
          q.push(g[i].e);
        }
      }
    }
    return dep[T] != -1;
  }
  int dfs(int np, int inflow) {
    if (np == T || !inflow) return inflow;
    int f, delta = 0;
    for (int i = cur[np]; i != -1; i = g[i].nxt) {
      cur[np] = i;
      if (dep[g[i].e] == dep[np] + 1 &&
          (f = dfs(g[i].e, min(inflow, g[i].cap))) > 0) {
        delta += f;
        inflow -= f;
        g[i].cap -= f;
        g[i ^ 1].cap += f;
        if (!inflow) break;
      }
    }
    return delta;
  }
  int dinic() {
    int ret = 0;
    while (bfs()) {
      memcpy(cur, head, sizeof(cur));
      ret += dfs(S, 0x3f3f3f3f);
    }
    return ret;
  }
};
int n, m, x[N], y[N], lsx[N], lsy[N], cx[N], cy[N], mnx[N], mny[N], r, b, p[N];
class limited_flow {
 public:
  graph G;
  int S, T, SS, TT, d[N << 1], bflow, pbet;
  void set(int s, int t, int ss, int tt) {
    S = s;
    T = t;
    SS = ss;
    TT = tt;
  }
  void init() {
    G.init();
    memset(d, 0, sizeof(d));
    bflow = 0;
  }
  int addedge(int s, int e, int l, int r) {
    if (l > r) {
      puts("-1");
      exit(0);
    }
    d[s] += l;
    d[e] -= l;
    return G.addedge(s, e, r - l);
  }
  void build() {
    for (int i = 1; i <= 2 * n; i++) {
      if (d[i] < 0) G.addedge(SS, i, -d[i]);
      if (d[i] > 0) G.addedge(i, TT, d[i]), bflow += d[i];
    }
    pbet = G.addedge(T, S, 0x3f3f3f3f);
  }
  int maxflow() {
    G.set(SS, TT);
    if (G.dinic() != bflow) return -1;
    int ret = G.g[pbet ^ 1].cap;
    for (int i = G.head[SS]; i != -1; i = G.g[i].nxt)
      G.g[i].cap = G.g[i ^ 1].cap = 0;
    for (int i = G.head[TT]; i != -1; i = G.g[i].nxt)
      G.g[i].cap = G.g[i ^ 1].cap = 0;
    G.g[pbet].cap = G.g[pbet ^ 1].cap = 0;
    G.set(S, T);
    ret += G.dinic();
    return ret;
  }
} G;
bool swp;
int main() {
  G.init();
  scanf("%d%d%d%d", &n, &m, &r, &b);
  if (r > b) swap(r, b), swp = 1;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &x[i], &y[i]), lsx[i] = x[i], lsy[i] = y[i];
  sort(lsx + 1, lsx + n + 1);
  sort(lsy + 1, lsy + n + 1);
  int cntx = unique(lsx + 1, lsx + n + 1) - lsx - 1,
      cnty = unique(lsy + 1, lsy + n + 1) - lsy - 1;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(lsx + 1, lsx + cntx + 1, x[i]) - lsx;
    y[i] = lower_bound(lsy + 1, lsy + cnty + 1, y[i]) - lsy;
    cx[x[i]]++;
    cy[y[i]]++;
  }
  for (int i = 1; i <= cntx; i++) mnx[i] = cx[i];
  for (int i = 1; i <= cnty; i++) mny[i] = cy[i];
  for (int i = 1, a, b, c; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      int p = lower_bound(lsx + 1, lsx + cntx + 1, b) - lsx;
      if (lsx[p] == b) mnx[p] = min(mnx[p], c);
    } else {
      int p = lower_bound(lsy + 1, lsy + cnty + 1, b) - lsy;
      if (lsy[p] == b) mny[p] = min(mny[p], c);
    }
  }
  G.set(cntx + cnty + 1, cntx + cnty + 2, cntx + cnty + 3, cntx + cnty + 4);
  for (int i = 1; i <= n; i++) p[i] = G.addedge(x[i], y[i] + cntx, 0, 1);
  for (int i = 1; i <= cntx; i++) {
    if ((mnx[i] ^ cx[i]) & 1) mnx[i]--;
    if (mnx[i] < 0) {
      puts("-1");
      return 0;
    }
    G.addedge(G.S, i, (cx[i] - mnx[i]) / 2, (cx[i] + mnx[i]) / 2);
  }
  for (int i = 1; i <= cnty; i++) {
    if ((mny[i] ^ cy[i]) & 1) mny[i]--;
    if (mny[i] < 0) {
      puts("-1");
      return 0;
    }
    G.addedge(i + cntx, G.T, (cy[i] - mny[i]) / 2, (cy[i] + mny[i]) / 2);
  }
  G.build();
  int vl = G.maxflow();
  if (vl == -1)
    puts("-1");
  else {
    printf("%lld\n", 1ll * b * n + 1ll * (r - b) * vl);
    for (int i = 1; i <= n; i++)
      putchar((G.G.g[p[i] ^ 1].cap != 0) ^ swp ? 'r' : 'b');
  }
  return 0;
}