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;
struct pi {
  int to;
  int cost;
  int rev;
  int id;
} pp;
vector<pi> g[200015];
queue<int> q;
int s, t;
int line[200015], leve[200015];
int min(int a, int b) {
  int p;
  p = a;
  if (b < a) p = b;
  return p;
}
void add(int a, int b, int cos, int id) {
  pp.to = b;
  pp.cost = cos;
  pp.id = id;
  pp.rev = (int)g[b].size();
  g[a].push_back(pp);
  pp.to = a;
  pp.cost = 0;
  pp.id = id;
  pp.rev = (int)g[a].size() - 1;
  g[b].push_back(pp);
  return;
}
void insert(int a, int b, int l, int r) {
  add(s, b, l, -1);
  add(a, b, r - l, -1);
  add(a, t, l, -1);
}
void bfs(void) {
  q.push(s);
  int p, f, i;
  while (!q.empty()) {
    p = q.front();
    q.pop();
    f = (int)g[p].size();
    for (i = 0; i < f; i++) {
      pi &e = g[p][i];
      if (e.cost > 0 && line[e.to] < 0) {
        line[e.to] = line[p] + 1;
        q.push(e.to);
      }
    }
  }
  return;
}
int dfs(int v, int f) {
  int p;
  if (v == t) return f;
  for (int &i = leve[v]; i < g[v].size(); i++) {
    pi &e = g[v][i];
    if (line[v] < line[e.to] && e.cost > 0) {
      p = dfs(e.to, min(f, e.cost));
      if (p > 0) {
        e.cost -= p;
        g[e.to][e.rev].cost += p;
        return p;
      }
    }
  }
  return 0;
}
int dinic() {
  int f;
  int flow = 0;
  while (1) {
    memset(line, -1, sizeof(line));
    memset(leve, 0, sizeof(leve));
    line[s] = 0;
    bfs();
    if (line[t] < 0) return flow;
    f = dfs(s, 100000000);
    if (f == 0) continue;
    flow += f;
    while ((f = dfs(s, 100000000)) > 0) {
      flow += f;
    }
  }
}
int x[200015], y[200015];
struct in {
  int x, y;
} pp1[200015];
int l[200015], r[200015];
int ans[200015];
set<int> xx, yy;
int up[200015], dow[200015];
int main() {
  int n, m;
  int u = 0;
  int r1, b1;
  cin >> n >> m;
  cin >> r1 >> b1;
  if (r1 < b1) {
    u = 1;
    swap(r1, b1);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &pp1[i].x, &pp1[i].y);
    x[i] = pp1[i].x;
    y[i] = pp1[i].y;
    xx.insert(x[i]);
    yy.insert(y[i]);
  }
  sort(x + 1, x + 1 + n);
  sort(y + 1, y + 1 + n);
  for (int i = 1; i <= n; i++) {
    pp1[i].x = lower_bound(x + 1, x + 1 + n, pp1[i].x) - x;
    pp1[i].y = lower_bound(y + 1, y + 1 + n, pp1[i].y) - y;
    add(pp1[i].x, pp1[i].y + n, 1, i);
    l[pp1[i].x]++;
    r[pp1[i].y]++;
  }
  s = 0;
  t = 2 * n + 3;
  for (int i = 1; i <= n; i++) {
    up[i] = l[i];
    dow[i] = r[i];
  }
  for (int i = 0; i < m; i++) {
    int p, x1, d;
    scanf("%d%d%d", &p, &x1, &d);
    if (p == 1) {
      if (xx.find(x1) == xx.end()) continue;
      x1 = lower_bound(x + 1, x + 1 + n, x1) - x;
      up[x1] = min(up[x1], d);
    } else {
      if (yy.find(x1) == yy.end()) continue;
      x1 = lower_bound(y + 1, y + 1 + n, x1) - y;
      dow[x1] = min(dow[x1], d);
    }
  }
  for (int i = 1; i <= n; i++) {
    int u0, d0;
    u0 = (l[i] + up[i]) / 2;
    d0 = (l[i] - up[i]) / 2;
    if (2 * d0 < l[i] - up[i]) d0++;
    if (u0 < d0) {
      printf("-1\n");
      return 0;
    } else {
      if (d0 < 0) d0 = 0;
      insert(2 * n + 1, i, d0, u0);
    }
    u0 = (r[i] + dow[i]) / 2;
    d0 = (r[i] - dow[i]) / 2;
    if (2 * d0 < r[i] - dow[i]) d0++;
    if (u0 < d0) {
      printf("-1\n");
      return 0;
    } else {
      if (d0 < 0) d0 = 0;
      insert(n + i, 2 * n + 2, d0, u0);
    }
  }
  dinic();
  add(2 * n + 2, 2 * n + 1, 100000000, -1);
  dinic();
  int flag = 0;
  for (pi v : g[s]) {
    if (v.cost > 0) flag = 1;
  }
  if (flag)
    printf("-1\n");
  else {
    int w = 0;
    for (pi v : g[2 * n + 1]) {
      if (v.to == 2 * n + 2) {
        w = v.cost;
      }
    }
    long long s = (long long)w * r1 + (long long)(n - w) * b1;
    cout << s << endl;
    for (int i = 1; i <= n; i++) {
      for (pi v : g[i]) {
        if (v.cost == 0 && v.id != -1) {
          ans[v.id] = 1;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      if (u == 0) {
        if (ans[i])
          printf("r");
        else
          printf("b");
      } else {
        if (ans[i])
          printf("b");
        else
          printf("r");
      }
    }
    printf("\n");
  }
}