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 maxn = 200100;
const int maxm = 1000010;
const int N = 100010;
const int inf = 0x3f3f3f3f;
int he[maxn], dep[maxn], cur[maxn], flow[maxn];
int ed = 1, n, m, cntx, cnty;
long long R, B;
map<int, int> mpx, mpy;
int X[N], Y[N], Limx[N], Limy[N], Id[N];
struct Edge {
  int v, nx, cap;
  Edge(int _v, int _nx, int _cap) {
    v = _v;
    nx = _nx;
    cap = _cap;
  }
  Edge() { ; }
} e[maxm];
void Add(int u, int v, int cap) {
  e[++ed] = Edge(v, he[u], cap);
  he[u] = ed;
  e[++ed] = Edge(u, he[v], 0);
  he[v] = ed;
}
void Qread(int &x) {
  char ch;
  x = 0;
  while (ch = getchar(), ch < '0' || ch > '9')
    ;
  x = ch - 48;
  while (ch = getchar(), ch >= '0' && ch <= '9') x = 10 * x + ch - 48;
}
struct NetFlows {
  int S, T;
  bool Bfs() {
    memset(dep, -1, sizeof(dep));
    queue<int> Q;
    Q.push(S);
    dep[S] = 0;
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      for (int i = he[u]; i; i = e[i].nx) {
        if (e[i].cap && dep[e[i].v] == -1) {
          dep[e[i].v] = dep[u] + 1;
          Q.push(e[i].v);
        }
      }
    }
    return dep[T] != -1;
  }
  int Dfs(int x, int w) {
    if (x == T || w == 0) return w;
    int res = 0;
    for (int &i = cur[x]; i; i = e[i].nx) {
      if (e[i].cap && dep[e[i].v] == dep[x] + 1) {
        int tmp = Dfs(e[i].v, min(e[i].cap, w));
        res += tmp;
        w -= tmp;
        e[i].cap -= tmp;
        e[i ^ 1].cap += tmp;
        if (w == 0) break;
      }
    }
    if (!res) dep[x] = -1;
    return res;
  }
  int Dinic(int _S, int _T) {
    S = _S;
    T = _T;
    int res = 0;
    while (Bfs()) {
      memcpy(cur, he, sizeof(he));
      res += Dfs(S, inf);
    }
    return res;
  }
} D;
void Del(int x) {
  for (int i = he[x]; i; i = e[i].nx) {
    e[i].cap = e[i ^ 1].cap = 0;
  }
}
int main() {
  int S = 0, T = 200090;
  int _S = T + 1, _T = T + 2;
  scanf("%d%d%lld%lld", &n, &m, &R, &B);
  int x, y;
  for (int i = 1; i <= n; ++i) {
    Qread(x);
    Qread(y);
    int tmpx = mpx[x];
    if (!tmpx) mpx[x] = tmpx = ++cntx;
    X[tmpx]++;
    int tmpy = mpy[y];
    if (!tmpy) mpy[y] = tmpy = ++cnty;
    Y[tmpy]++;
    Add(tmpx, tmpy + N, 1);
    Id[i] = ed - 1;
  }
  for (int i = 1; i <= cntx; ++i) Limx[i] = X[i];
  for (int i = 1; i <= cnty; ++i) Limy[i] = Y[i];
  int t, l, d, a, b, tmp;
  for (int i = 1; i <= m; ++i) {
    Qread(t);
    Qread(l);
    Qread(d);
    if (t == 1) {
      tmp = mpx[l];
      if (!tmp) continue;
      Limx[tmp] = min(Limx[tmp], d);
    } else {
      tmp = mpy[l];
      if (!tmp) continue;
      Limy[tmp] = min(Limy[tmp], d);
    }
  }
  for (int i = 1; i <= cntx; ++i) {
    a = (X[i] + Limx[i]) / 2, b = ceil((double)(X[i] - Limx[i]) / 2.0);
    if (X[i] < b || b > a) {
      printf("-1");
      return 0;
    }
    flow[S] -= b;
    flow[i] += b;
    Add(S, i, a - b);
  }
  for (int i = 1; i <= cnty; ++i) {
    a = (Y[i] + Limy[i]) >> 1, b = ceil((double)(Y[i] - Limy[i]) / 2.0);
    if (Y[i] < b || b > a) {
      printf("-1");
      return 0;
    }
    flow[N + i] -= b;
    flow[T] += b;
    Add(N + i, T, a - b);
  }
  int res = 0;
  for (int i = S; i <= cntx; ++i) {
    if (flow[i] < 0)
      Add(i, _T, -flow[i]);
    else
      Add(_S, i, flow[i]), res += flow[i];
  }
  for (int i = N + 1; i <= N + cnty; ++i) {
    if (flow[i] < 0)
      Add(i, _T, -flow[i]);
    else
      Add(_S, i, flow[i]), res += flow[i];
  }
  if (flow[T] < 0)
    Add(T, _T, -flow[T]);
  else
    Add(_S, T, flow[T]), res += flow[T];
  Add(T, S, inf);
  if (D.Dinic(_S, _T) != res) {
    printf("-1");
    return 0;
  }
  long long Flow = (long long)e[ed].cap;
  e[ed].cap = e[ed ^ 1].cap = 0;
  Del(_S);
  Del(_T);
  Flow += (long long)D.Dinic(S, T);
  if (R < B) {
    printf("%lld\n", Flow * R + ((long long)n - Flow) * B);
    for (int i = 1; i <= n; ++i) {
      if (!e[Id[i]].cap)
        printf("r");
      else
        printf("b");
    }
  } else {
    printf("%lld\n", Flow * B + (n - Flow) * R);
    for (int i = 1; i <= n; ++i) {
      if (!e[Id[i]].cap)
        printf("b");
      else
        printf("r");
    }
  }
  return 0;
}