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;
bool home = 1;
signed realMain();
int kek;
bool acum;
time_t bg, nd;
signed main() {
  home = 0;
  if (home) {
    freopen("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  bg = clock();
  realMain();
}
const int INF = (int)1e9;
struct flow {
  struct edge {
    int to;
    int cap;
    int spre;
  };
  const int INF = (int)1e9;
  int n;
  vector<int> head;
  vector<edge> edges;
  vector<int> level;
  vector<int> pt;
  void init(int nn) {
    n = nn;
    edges.clear();
    head.resize(n + 1, -1);
    pt.resize(n + 1);
    level.resize(n + 1);
  }
  void add(int a, int b, int c, int d = 0) {
    edges.push_back({b, c, head[a]});
    edges.push_back({a, d, head[b]});
    head[a] = (int)edges.size() - 2;
    head[b] = (int)edges.size() - 1;
  }
  int dfs(int a, int cap) {
    if (cap == 0 || a == n) {
      return cap;
    }
    while (pt[a] != -1) {
      int i = pt[a];
      if (edges[i].cap && level[edges[i].to] == 1 + level[a]) {
        int b = edges[i].to;
        int x = dfs(b, min(cap, edges[i].cap));
        if (x > 0) {
          edges[i].cap -= x;
          edges[i ^ 1].cap += x;
          return x;
        }
      }
      pt[a] = edges[pt[a]].spre;
    }
    return 0;
  }
  int get() {
    int ret = 0;
    while (1) {
      for (int i = 1; i <= n; i++) {
        level[i] = -1;
        pt[i] = 0;
      }
      level[1] = 0;
      queue<int> q;
      q.push(1);
      while (!q.empty()) {
        int a = q.front();
        q.pop();
        int ind = head[a];
        while (ind != -1) {
          if (edges[ind].cap > 0) {
            int b = edges[ind].to;
            if (level[b] == -1) {
              level[b] = 1 + level[a];
              q.push(b);
            }
          }
          ind = edges[ind].spre;
        }
      }
      if (level[n] == -1) {
        break;
      }
      pt = head;
      while (1) {
        int x = dfs(1, INF);
        if (x == 0) {
          break;
        }
        ret += x;
      }
    }
    return ret;
  }
};
struct demand_flow {
  int n;
  struct edge {
    int from;
    int to;
    int lo;
    int hi;
    int taken;
    int id;
  };
  vector<edge> edges;
  void init(int nn) {
    n = nn;
    edges.clear();
  }
  void add(int a, int b, int lo, int hi) {
    edge it;
    it.from = a;
    it.to = b;
    it.lo = lo;
    it.hi = hi;
    it.taken = 0;
    it.id = 0;
    edges.push_back(it);
  }
  int ret;
  bool good;
  void rec() {
    ret = 0;
    good = 1;
    flow gbig;
    gbig.init(n + 2);
    gbig.add(1 + n, 1 + 1, INF);
    int slo = 0;
    for (auto &it : edges) {
      if (it.lo > it.hi) {
        good = 0;
        return;
      }
      if (it.hi == 0) continue;
      slo += it.lo;
      it.taken = 0;
      it.id = (int)gbig.edges.size();
      assert(it.lo >= 0);
      gbig.add(1 + it.from, 1 + it.to, it.hi - it.lo);
      gbig.add(1, 1 + it.to, it.lo);
      gbig.add(1 + it.from, 2 + n, it.lo);
    }
    kek = slo;
    if (gbig.get() != slo) {
      good = 0;
      return;
    }
    flow rl;
    rl.init(n);
    for (auto &it : edges) {
      if (it.hi == 0) continue;
      int new_id = (int)rl.edges.size();
      rl.add(it.from, it.to, gbig.edges[it.id].cap, gbig.edges[it.id ^ 1].cap);
      it.id = new_id;
    }
    int val = rl.get();
    for (auto &it : edges) {
      if (it.hi == 0) continue;
      it.taken = it.lo + rl.edges[it.id ^ 1].cap;
      if (it.from == 1) {
        ret += it.taken;
      }
      if (it.to == 1) {
        ret -= it.taken;
      }
    }
    for (auto &it : edges) {
    }
  }
};
const int N = (int)1e5 + 7;
int n, m, r, b, x[N], y[N], id[N];
int sx[N], sy[N], catex[N], catey[N];
pair<int, int> compute(int total, int cnt) {
  return {(total - cnt + 1) / 2, (total + cnt) / 2};
}
signed realMain() {
  cin >> n >> m >> r >> b;
  acum = (n == 100000);
  map<int, int> nox, noy;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    nox[x[i]] = 0;
    noy[y[i]] = 0;
    sx[i] = sy[i] = N;
  }
  int ind = 0;
  for (auto &it : nox) {
    it.second = ++ind;
  }
  ind = 0;
  for (auto &it : noy) {
    it.second = ++ind;
  }
  for (int i = 1; i <= n; i++) catex[nox[x[i]]]++;
  for (int i = 1; i <= n; i++) catey[noy[y[i]]]++;
  int cx = (int)nox.size(), cy = (int)noy.size();
  while (m--) {
    int tp, l, d;
    cin >> tp >> l >> d;
    if (tp == 1) {
      if (nox.count(l)) {
        sx[nox[l]] = min(sx[nox[l]], d);
      }
    } else {
      if (noy.count(l)) {
        sy[noy[l]] = min(sy[noy[l]], d);
      }
    }
  }
  demand_flow f;
  f.init(1 + cx + cy + 1);
  int ha = 0;
  for (int i = 1; i <= cx; i++) {
    auto it = compute(catex[i], sx[i]);
    it.first = max(it.first, 0);
    f.add(1, 1 + i, it.first, it.second);
    ha ^= it.first;
    ha ^= it.second;
  }
  for (int i = 1; i <= cy; i++) {
    auto it = compute(catey[i], sy[i]);
    it.first = max(it.first, 0);
    f.add(1 + cx + i, 1 + cx + cy + 1, it.first, it.second);
    ha ^= it.first * 123;
    ha += it.second * 429;
  }
  for (int i = 1; i <= n; i++) {
    id[i] = (int)f.edges.size();
    f.add(1 + nox[x[i]], 1 + cx + noy[y[i]], 0, 1);
  }
  f.rec();
  if (f.good == 0) {
    cout << "-1\n";
    return 0;
  }
  string kek = "rb";
  int cnt = f.ret;
  if (r > b) {
    swap(r, b);
    kek = "br";
  }
  cout << (long long)cnt * r + (long long)(n - cnt) * b << "\n";
  for (int i = 1; i <= n; i++) {
    int val = f.edges[id[i]].taken;
    assert(val == 0 || val == 1);
    cout << kek[1 - val];
  }
  cout << "\n";
  return 0;
}