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 MAX_N = 2e5 + 200, MAX_E = 1e6 + 2000;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n, m, head[MAX_N], red, blue, xi[MAX_N], yi[MAX_N], gS, gT;
int start_pos, end_pos, current, unit, ptid, dep[MAX_N], cur[MAX_N], idx[MAX_N];
long long di[MAX_N];
bool swapped, fuckflag;
map<int, int> mpx, mpy, cntx, cnty, constx, consty;
struct edge {
  int to, nxt;
  long long weight;
} edges[MAX_E << 1];
void addpath(int src, int dst, long long weight) {
  edges[current].to = dst, edges[current].nxt = head[src];
  edges[current].weight = weight, head[src] = current++;
}
void addtube(int src, int dst, long long weight) {
  addpath(src, dst, weight);
  addpath(dst, src, 0);
}
void addtube(int src, int dst, long long lower, long long upper) {
  if (lower > upper) {
    puts("-1");
    if (fuckflag)
      puts("Fuck void addtube() :: occured for the illegal interval.");
    exit(0);
  }
  addtube(src, dst, upper - lower), di[src] -= lower, di[dst] += lower;
}
bool bfs() {
  memset(dep, 0, sizeof(dep));
  queue<int> q;
  q.push(start_pos), dep[start_pos] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i != -1; i = edges[i].nxt)
      if (dep[edges[i].to] == 0 && edges[i].weight > 0)
        dep[edges[i].to] = dep[u] + 1, q.push(edges[i].to);
  }
  return dep[end_pos] != 0;
}
long long dfs(int u, long long flow) {
  if (u == end_pos || flow == 0) return flow;
  for (int &i = cur[u]; i != -1; i = edges[i].nxt)
    if (edges[i].weight > 0 && dep[edges[i].to] == dep[u] + 1)
      if (long long di = dfs(edges[i].to, min(flow, edges[i].weight))) {
        edges[i].weight -= di, edges[i ^ 1].weight += di;
        return di;
      }
  return 0;
}
long long dinic() {
  long long ret = 0;
  while (bfs()) {
    memcpy(cur, head, sizeof(cur));
    while (long long di = dfs(start_pos, INF)) ret += di;
  }
  return ret;
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d%d%d", &n, &m, &red, &blue);
  fuckflag |=
      (n == 100000 && m == 100000 && red == 341412296 && blue == 266451126);
  if (red < blue) swapped = true, swap(red, blue);
  unit = blue - red, gS = n + m + 1, gT = n + m + 2, ptid = n;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &xi[i], &yi[i]), cntx[xi[i]]++, cnty[yi[i]]++;
  for (int i = 1, opt, x, d; i <= m; i++) {
    scanf("%d%d%d", &opt, &x, &d);
    if (opt == 1) {
      if (!mpx.count(x)) mpx[x] = ++ptid;
      if (!constx.count(x))
        constx[x] = d;
      else
        constx[x] = min(constx[x], d);
    } else {
      if (!mpy.count(x)) mpy[x] = ++ptid;
      if (!consty.count(x))
        consty[x] = d;
      else
        consty[x] = min(consty[x], d);
    }
  }
  for (auto curt : constx)
    if (cntx[curt.first] <= curt.second)
      addtube(gS, mpx[curt.first], 0, INF);
    else
      addtube(gS, mpx[curt.first], (cntx[curt.first] - curt.second + 1) >> 1,
              (cntx[curt.first] + curt.second) >> 1);
  for (auto curt : consty)
    if (cnty[curt.first] <= curt.second)
      addtube(mpy[curt.first], gT, 0, INF);
    else
      addtube(mpy[curt.first], gT, (cnty[curt.first] - curt.second + 1) >> 1,
              (cnty[curt.first] + curt.second) >> 1);
  for (int i = 1; i <= n; i++) {
    idx[i] = current;
    if (mpx.count(xi[i]))
      addtube(mpx[xi[i]], i, 1);
    else
      addtube(gS, i, 1);
    if (mpy.count(yi[i]))
      addtube(i, mpy[yi[i]], 1);
    else
      addtube(i, gT, 1);
  }
  start_pos = n + m + 3, end_pos = start_pos + 1;
  long long sum = 0;
  for (int i = 1; i <= n + m + 2; i++)
    if (di[i] > 0)
      addtube(start_pos, i, di[i]), sum += di[i];
    else if (di[i] < 0)
      addtube(i, end_pos, -di[i]);
  addtube(gT, gS, INF);
  long long ret = dinic();
  bool flag = sum == ret;
  if (flag == false) {
    puts("-1");
    if (fuckflag)
      puts(
          "Fuck int main() :: if (flag == false), occured at the illegal "
          "network.");
    exit(0);
  }
  ret = edges[current - 1].weight;
  edges[current - 1].weight = edges[current - 2].weight = 0;
  start_pos = gS, end_pos = gT, ret += dinic();
  long long ans = 1LL * ret * unit + 1LL * n * red;
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++)
    if (edges[idx[i]].weight == 0)
      putchar(swapped ? 'r' : 'b');
    else
      putchar(swapped ? 'b' : 'r');
  return 0;
}