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 static int N = 1e5 + 7;
const static int M = 1e5 + 7;
const int static inf = 1e9;
int p[N][2];
int c[M][3];
int pNum[M];
int pp[2 * N + 6 * M][4], pi;
int ppBak[2 * N + 6 * M][4];
int ss[M];
int cc[M];
int lev[M];
int startPoint, endPoint;
char ansColor[N];
void addE(int f, int to, int cap, int id) {
  ++pi;
  pp[pi][0] = to;
  pp[pi][1] = cap;
  pp[pi][2] = id;
  pp[pi][3] = ss[f];
  ss[f] = pi;
}
void add(int from, int to, int cap, int id) {
  addE(from, to, cap, id);
  addE(to, from, 0, id);
}
bool bfs(int s, int e) {
  memset(lev, 0, sizeof(lev));
  memcpy(cc, ss, sizeof(cc));
  lev[s] = 1;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int i = cc[v]; i; i = pp[i][3]) {
      int to = pp[i][0];
      if (lev[to] == 0 && pp[i][1] > 0) {
        que.push(to);
        lev[to] = lev[v] + 1;
      }
    }
  }
  return lev[e] > 0;
}
int dfs(int v, int f) {
  if (v == endPoint) {
    return f;
  }
  int rf = f;
  int i = cc[v];
  for (; i; i = pp[i][3]) {
    int to = pp[i][0];
    int lf = pp[i][1];
    if (lev[v] == lev[to] - 1 && lf > 0) {
      int tmp = dfs(to, min(f, lf));
      pp[i][1] -= tmp;
      f -= tmp;
      pp[i + ((i & 1) ? 1 : -1)][1] += tmp;
      if (f == 0) {
        break;
      }
    }
  }
  cc[v] = i;
  return rf - f;
}
int mf() {
  int ans = 0;
  while (bfs(startPoint, endPoint)) {
    int tmp = dfs(startPoint, inf);
    if (tmp == 0) {
      break;
    }
    ans += tmp;
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int costR, costB;
  scanf("%d%d", &costR, &costB);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &p[i][0], &p[i][1]);
  }
  unordered_map<int, int> mp[2];
  for (int i = 0; i < m; ++i) {
    int t, l, d;
    scanf("%d%d%d", &t, &l, &d);
    --t;
    c[i][0] = t;
    c[i][1] = l;
    c[i][2] = d;
    if (mp[t].count(l) == 0) {
      mp[t][l] = i;
    } else if (c[mp[t][l]][2] > d) {
      mp[t][l] = i;
    }
  }
  long long ans = 0;
  int minCost = min(costR, costB);
  int maxCost = max(costR, costB);
  char minColor = costR < costB ? 'r' : 'b';
  char maxColor = minColor == 'r' ? 'b' : 'r';
  int s = m + 1;
  int t = s + 1;
  int ss = t + 1;
  int tt = ss + 1;
  startPoint = ss;
  endPoint = tt;
  queue<int> que;
  for (int i = 0; i < n; ++i) {
    int id[2] = {-1, -1};
    for (int j = 0; j < 2; ++j) {
      if (mp[j].count(p[i][j]) > 0) {
        id[j] = mp[j][p[i][j]];
        ++pNum[id[j]];
      }
    }
    if (id[0] >= 0) {
      if (id[1] >= 0) {
        add(id[0], id[1], 1, i);
      } else {
        add(id[0], t, 1, i);
      }
    } else if (id[1] >= 0) {
      add(s, id[1], 1, i);
    } else {
      ans += minCost;
      ansColor[i] = minColor;
    }
  }
  int minMf = 0;
  int s2tt = 0;
  int ss2t = 0;
  for (int i = 0; i < m; ++i) {
    if (mp[c[i][0]][c[i][1]] != i) {
      continue;
    }
    int allPoints = pNum[i];
    int d = c[i][2];
    int minF = max(0, (allPoints - d + 1) / 2);
    int maxF = min(allPoints, (allPoints + d) / 2);
    minMf += minF;
    if (minF > maxF) {
      printf("-1");
      return 0;
    }
    if (c[i][0] == 0) {
      add(ss, i, minF, -1);
      s2tt += minF;
      if (maxF > minF) {
        add(s, i, maxF - minF, -1);
      }
    } else {
      add(i, tt, minF, -1);
      ss2t += minF;
      if (maxF > minF) {
        add(i, t, maxF - minF, -1);
      }
    }
  }
  add(s, tt, s2tt, -1);
  add(ss, t, ss2t, -1);
  add(t, s, inf, -1);
  memcpy(ppBak, pp, sizeof(pp[0]) * (1 + pi));
  int mmf = mf();
  if (mmf < minMf) {
    printf("-1");
    return 0;
  }
  int minFlowCost = pp[pi][1];
  for (int from = mmf / 2, to = minFlowCost; from <= to;) {
    int tmp = (from + to) >> 1;
    memcpy(pp, ppBak, sizeof(pp[0]) * (pi + 1));
    pp[pi - 1][1] = tmp;
    if (mf() == mmf) {
      to = min(tmp, pp[pi][1]) - 1;
      minFlowCost = tmp;
    } else {
      from = tmp + 1;
    }
  }
  memcpy(pp, ppBak, sizeof(pp[0]) * (pi + 1));
  pp[pi - 1][1] = minFlowCost;
  mf();
  for (int i = 1; i < pi; i += 2) {
    int id = pp[i][2];
    if (id >= 0) {
      if (pp[i][1] == 0) {
        ansColor[id] = maxColor;
        ans += maxCost;
      } else {
        ansColor[id] = minColor;
        ans += minCost;
      }
    }
  }
  cout << ans << endl;
  cout << ansColor;
  return 0;
}