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 = 400005;
const long long inf = 1e18;
namespace dinic {
using cap_type = long long;
using edg_type = pair<long long, long long>;
const cap_type inf = 1e18;
const int MAXN = 400005;
struct edge {
  int des, opo;
  cap_type cap;
};
vector<edge> adj[MAXN];
int n, dis[MAXN], pnt[MAXN];
void init(int N, vector<edg_type> V[]) {
  n = N;
  for (int i = 1; i <= n; i++) {
    adj[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    for (auto &T : V[i]) {
      int A;
      cap_type B;
      tie(A, B) = T;
      adj[i].push_back({A, (int)adj[A].size(), B});
      adj[A].push_back({i, (int)adj[i].size() - 1, 0});
    }
  }
}
bool bfs(int src, int snk) {
  fill(dis + 1, dis + 1 + n, 0);
  fill(pnt + 1, pnt + 1 + n, 0);
  queue<int> Q;
  Q.push(src);
  dis[src] = 1;
  while (!Q.empty()) {
    int C = Q.front();
    Q.pop();
    for (auto &T : adj[C]) {
      if (T.cap > 0 && !dis[T.des]) {
        dis[T.des] = dis[C] + 1;
        Q.push(T.des);
      }
    }
  }
  return dis[snk] > 0;
}
cap_type dfs(int C, int S, cap_type F) {
  if (C == S) return F;
  for (; pnt[C] < (int)adj[C].size(); pnt[C]++) {
    auto &T = adj[C][pnt[C]];
    if (T.cap == 0 || dis[T.des] != dis[C] + 1) continue;
    cap_type R = dfs(T.des, S, min(F, T.cap));
    if (R == 0) continue;
    T.cap -= R;
    adj[T.des][T.opo].cap += R;
    return R;
  }
  return 0;
}
cap_type match(int src, int snk) {
  cap_type R = 0;
  while (bfs(src, snk)) {
    cap_type T;
    while ((T = dfs(src, snk, inf))) R += T;
  }
  return R;
}
};  // namespace dinic
struct compressor {
  vector<int> v;
  void ins(int V) { v.push_back(V); }
  void cpr() {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
  }
  int get(int V) { return lower_bound(v.begin(), v.end(), V) - v.begin(); }
} xcp, ycp;
int n, m, r, b, xc[N], yc[N], x[N], y[N], cit[N];
bool vis[N];
vector<pair<long long, long long> > adj[N], xl, yl;
int main() {
  scanf("%d%d%d%d", &n, &m, &r, &b);
  long long D = abs(r - b);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    xcp.ins(x[i]);
    ycp.ins(y[i]);
  }
  for (int i = 1; i <= m; i++) {
    int T, A, B;
    scanf("%d%d%d", &T, &A, &B);
    if (T == 1) {
      xl.push_back({B, A});
      xcp.ins(A);
    } else {
      yl.push_back({B, A});
      ycp.ins(A);
    }
  }
  xcp.cpr();
  ycp.cpr();
  int SX = xcp.v.size(), SY = ycp.v.size();
  for (int i = 1; i <= n; i++) {
    x[i] = xcp.get(x[i]) + 1;
    y[i] = ycp.get(y[i]) + 1;
    xc[x[i]]++;
    yc[y[i]]++;
    adj[x[i]].push_back({SX + y[i], 1});
  }
  sort(xl.begin(), xl.end());
  sort(yl.begin(), yl.end());
  long long LS = 0;
  for (auto &T : xl) {
    T.second = xcp.get(T.second) + 1;
    if (vis[T.second]) continue;
    vis[T.second] = true;
    int L = max(0ll, (xc[T.second] - T.first + 1) / 2),
        R = (xc[T.second] + T.first) / 2;
    if (L > R) {
      puts("-1");
      return 0;
    }
    adj[SX + SY + 1].push_back({SX + SY + 4, L});
    adj[SX + SY + 3].push_back({T.second, L});
    adj[SX + SY + 1].push_back({T.second, R - L});
    LS += L;
  }
  for (auto &T : yl) {
    T.second = ycp.get(T.second) + 1;
    if (vis[SX + T.second]) continue;
    vis[SX + T.second] = true;
    int L = max(0ll, (yc[T.second] - T.first + 1) / 2),
        R = (yc[T.second] + T.first) / 2;
    if (L > R) {
      puts("-1");
      return 0;
    }
    adj[SX + T.second].push_back({SX + SY + 4, L});
    adj[SX + SY + 3].push_back({SX + SY + 2, L});
    adj[SX + T.second].push_back({SX + SY + 2, R - L});
    LS += L;
  }
  for (long long i = 1; i <= SX + SY; i++) {
    if (vis[i]) continue;
    if (i <= SX)
      adj[SX + SY + 1].push_back({i, inf});
    else
      adj[i].push_back({SX + SY + 2, inf});
  }
  adj[SX + SY + 2].push_back({SX + SY + 1, inf});
  dinic::init(SX + SY + 4, adj);
  long long F1 = dinic::match(SX + SY + 3, SX + SY + 4);
  if (F1 != LS) {
    puts("-1");
    return 0;
  }
  long long F2 = dinic::match(SX + SY + 1, SX + SY + 2);
  string col = "";
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long T = !dinic::adj[x[i]][cit[x[i]]++].cap;
    ans += max(r, b) - T * D;
    col += ((T ^ (r < b)) ? 'b' : 'r');
  }
  printf("%lld\n%s\n", ans, col.c_str());
}