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 = 1e5 + 5;
char colors[3] = "rb";
int idx[N];
pair<int, int> p[N];
template <int N, int E, typename Type, Type INF>
class MaxFlow {
 public:
  int edge, node, bridge, src, dst, source, sink;
  int level[N], current[N];
  int first[N], next[E << 1], to[E << 1];
  Type cap[E << 1], hasTo;
  int Node() { return node++; }
  void Init() {
    node = 4, edge = 1;
    hasTo = src = 0, dst = 1, source = 2, sink = 3;
    memset(first, 0, sizeof(first));
    bridge = Add(sink, source, INF);
  }
  int add(int x, int y, Type z) {
    next[++edge] = first[x];
    first[x] = edge;
    to[edge] = y;
    cap[edge] = z;
    return edge;
  }
  int Add(int x, int y, Type z) {
    add(y, x, 0);
    return add(x, y, z);
  }
  void LRAdd(int x, int y, Type L, Type R) {
    if (L == 0)
      Add(x, y, R);
    else {
      hasTo += L;
      Add(src, y, L);
      Add(x, dst, L);
      Add(x, y, R - L);
    }
  }
  Type Dinic() {
    while (Bfs(src, dst)) Dfs(src, dst, INF);
    if (hasTo != GetFlow(src)) return -1;
    while (Bfs(source, sink)) Dfs(source, sink, INF);
    return GetFlow(source);
  }

 private:
  Type GetFlow(int x) {
    Type ans = 0;
    for (int go = first[x]; go; go = next[go])
      if ((go ^ 1) != bridge) ans += cap[go ^ 1];
    return ans;
  }
  bool Bfs(int source, int sink) {
    queue<int> q;
    fill(level, level + node, 0);
    q.push(source), level[source] = 1;
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (int go = current[x] = first[x]; go; go = next[go])
        if (cap[go] > 0 && !level[to[go]]) {
          int y = to[go];
          level[y] = level[x] + 1;
          q.push(y);
        }
    }
    return level[sink];
  }
  Type Dfs(int x, int sink, Type flow) {
    if (x == sink || flow == 0) return flow;
    Type ans = 0, tmp;
    for (int &go = current[x]; go; go = next[go])
      if (cap[go] > 0) {
        int y = to[go];
        if (level[y] == level[x] + 1 &&
            (tmp = Dfs(y, sink, min(flow, cap[go]))) > 0) {
          ans += tmp, flow -= tmp;
          cap[go] -= tmp, cap[go ^ 1] += tmp;
          if (flow == 0) break;
        }
      }
    return ans;
  }
};
MaxFlow<2 * N, 7 * N, int, 1 << 30> net;
int main() {
  int n, m, r, b;
  scanf("%d%d%d%d", &n, &m, &r, &b);
  if (r > b) {
    swap(r, b), swap(colors[0], colors[1]);
  }
  map<int, int> mp[2], cnt[2], up[2];
  net.Init();
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (!mp[0].count(x)) mp[0][x] = net.Node();
    if (!mp[1].count(y)) mp[1][y] = net.Node();
    p[i] = {mp[0][x], mp[1][y]};
    cnt[0][x]++, cnt[1][y]++;
  }
  for (int i = 0; i < 2; i++) up[i] = cnt[i];
  for (int i = 0; i < m; i++) {
    int type, x, y;
    scanf("%d%d%d", &type, &x, &y);
    type--;
    if (!up[type].count(x)) continue;
    up[type][x] = min(up[type][x], y);
  }
  for (int j = 0; j < 2; j++) {
    for (auto a = cnt[j].begin(), b = up[j].begin(); a != cnt[j].end();
         a++, b++) {
      int A = (*a).second, B = (*b).second;
      int L = (A - B + 1) / 2;
      int R = (A + B) / 2;
      if (L > R) {
        cout << -1 << endl;
        return 0;
      }
      if (j == 0) {
        net.LRAdd(net.source, mp[0][(*a).first], L, R);
      } else {
        net.LRAdd(mp[1][(*a).first], net.sink, L, R);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    idx[i] = net.Add(p[i].first, p[i].second, 1);
  }
  int ans = net.Dinic();
  if (ans < 0) {
    cout << -1 << endl;
    return 0;
  }
  string res = string(n, '#');
  for (int i = 0; i < n; i++) res[i] = colors[net.cap[idx[i]]];
  cout << 1LL * r * ans + 1LL * (n - ans) * b << endl;
  puts(res.c_str());
  return 0;
}