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 = 500111;
const int maxm = 2000111;
const int inf = 0x3f3f3f3f;
int head[maxn], cnt, dis[maxn], pre[maxn], cur[maxn], num[maxn];
struct edge {
  int from, to, next, id;
  long long cap;
} E[maxm];
void init(int n) {
  memset(head, -1, sizeof head);
  cnt = 0;
}
void add(int u, int v, long long c, int id = -1) {
  E[cnt].from = u;
  E[cnt].to = v;
  E[cnt].next = head[u];
  E[cnt].id = id;
  E[cnt].cap = c;
  head[u] = cnt++;
  E[cnt].from = v;
  E[cnt].to = u;
  E[cnt].next = head[v];
  E[cnt].id = id;
  E[cnt].cap = 0;
  head[v] = cnt++;
}
long long maxflow(int s, int t, int n) {
  memset(dis, 0x3f, sizeof dis);
  dis[t] = 0;
  queue<int> que;
  que.push(t);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = head[u]; ~i; i = E[i].next) {
      int v = E[i].to;
      if (dis[v] == inf && E[i].cap == 0) {
        dis[v] = dis[u] + 1;
        que.push(v);
      }
    }
  }
  memcpy(cur, head, sizeof cur);
  memset(num, 0, sizeof num);
  for (int i = 1; i <= n; i++)
    if (dis[i] != inf) num[dis[i]]++;
  long long ret = 0;
  int x = s;
  pre[s] = -1;
  while (dis[s] < n) {
    if (x == t) {
      long long f = 1LL << 62;
      for (int i = pre[t]; ~i; i = pre[E[i].from]) f = min(f, E[i].cap);
      for (int i = pre[t]; ~i; i = pre[E[i].from]) {
        E[i].cap -= f;
        E[i ^ 1].cap += f;
      }
      ret += f;
      x = s;
    }
    int ok = 0;
    for (int &i = cur[x]; ~i; i = E[i].next) {
      int v = E[i].to;
      if (dis[v] == dis[x] - 1 && E[i].cap) {
        pre[v] = i;
        x = v;
        ok = 1;
        break;
      }
    }
    if (!ok) {
      int mn = n - 1;
      for (int i = head[x]; ~i; i = E[i].next)
        if (E[i].cap) mn = min(mn, dis[E[i].to]);
      if (--num[dis[x]] == 0) break;
      num[dis[x] = mn + 1]++;
      cur[x] = head[x];
      if (x != s) x = E[pre[x]].from;
    }
  }
  return ret;
}
int x[maxn], y[maxn], xx[maxn], yy[maxn];
int t[maxn], l[maxn], d[maxn];
int v1[maxn], v2[maxn], num1[maxn], num2[maxn];
int deg[maxn], fg[maxn];
int main() {
  int n, m, r, b;
  scanf("%d%d%d%d", &n, &m, &r, &b);
  char ch1, ch2;
  int val1, val2, ok = 1;
  if (r < b) {
    ch1 = 'r', ch2 = 'b', val1 = r, val2 = b;
  } else {
    ch1 = 'b', ch2 = 'r', val1 = b, val2 = r;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", x + i, y + i);
    xx[i] = x[i], yy[i] = y[i];
  }
  int ct1 = n, ct2 = n;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", t + i, l + i, d + i);
    if (t[i] == 1) {
      xx[++ct1] = l[i];
    } else {
      yy[++ct2] = l[i];
    }
  }
  sort(xx + 1, xx + ct1 + 1);
  sort(yy + 1, yy + ct2 + 1);
  int n1 = unique(xx + 1, xx + ct1 + 1) - xx - 1;
  int n2 = unique(yy + 1, yy + ct2 + 1) - yy - 1;
  for (int i = 1; i <= n1; i++) v1[i] = inf;
  for (int i = 1; i <= n2; i++) v2[i] = inf;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(xx + 1, xx + n1 + 1, x[i]) - xx;
    y[i] = lower_bound(yy + 1, yy + n2 + 1, y[i]) - yy;
    num1[x[i]]++;
    num2[y[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    if (t[i] == 1) {
      l[i] = lower_bound(xx + 1, xx + n1 + 1, l[i]) - xx;
      v1[l[i]] = min(v1[l[i]], d[i]);
    } else {
      l[i] = lower_bound(yy + 1, yy + n2 + 1, l[i]) - yy;
      v2[l[i]] = min(v2[l[i]], d[i]);
    }
  }
  int s = n1 + n2 + 1, t = n1 + n2 + 2;
  int ss = t + 1, tt = t + 2;
  init(tt);
  for (int i = 1; i <= n; i++) {
    add(x[i], y[i] + n1, 1, i);
  }
  for (int i = 1; i <= n1; i++) {
    if (v1[i] == inf) {
      add(s, i, num1[i]);
    } else {
      int x1 = max(0, (num1[i] - v1[i] + 1) / 2);
      int x2 = min(num1[i], (num1[i] + v1[i]) / 2);
      if (x1 > x2) ok = 0;
      add(s, i, x2 - x1);
      if (x1) {
        deg[s] -= x1;
        deg[i] += x1;
      }
    }
  }
  for (int i = 1; i <= n2; i++) {
    if (v2[i] == inf) {
      add(i + n1, t, num2[i]);
    } else {
      int x1 = max(0, (num2[i] - v2[i] + 1) / 2);
      int x2 = min(num2[i], (num2[i] + v2[i]) / 2);
      if (x1 > x2) ok = 0;
      add(i + n1, t, x2 - x1);
      if (x1) {
        deg[i + n1] -= x1;
        deg[t] += x1;
      }
    }
  }
  add(t, s, inf);
  long long sum = 0;
  for (int i = 1; i <= t; i++) {
    if (deg[i] > 0) {
      sum += deg[i];
      add(ss, i, deg[i]);
    }
    if (deg[i] < 0) {
      add(i, tt, -deg[i]);
    }
  }
  if (!ok) {
    puts("-1");
    return 0;
  }
  long long mf = maxflow(ss, tt, tt);
  if (mf == sum) {
    head[ss] = head[tt] = -1;
    maxflow(s, t, tt);
    for (int i = 0; i < cnt; i++) {
      int u = E[i].from, v = E[i].to;
      if (u > n1 && u <= n1 + n2 && v > 0 && v <= n1 && E[i].cap) {
        fg[E[i].id] = 1;
      }
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += fg[i] ? val1 : val2;
    }
    printf("%I64d\n", ans);
    for (int i = 1; i <= n; i++) putchar(fg[i] ? ch1 : ch2);
    puts("");
  } else {
    puts("-1");
  }
  return 0;
}