Problem: Bob has put on some weight recently. In order to lose weight a bit, Bob has decided to swim regularly in the pool. However, the day before he went to the pool for the first time he had a weird dream. In this dream Bob was swimming along one of the pool's lanes, but also there were some jellyfish swimming around him. It's worth mentioning that jellyfish have always been one of Bob's deepest childhood fears.

Let us assume the following physical model for Bob's dream.

  1. The pool's lane is an area of the plane between lines x=0 and x=w. Bob is not allowed to swim outside of the lane, but he may touch its bounding lines if he wants. 
  2. The jellyfish are very small, but in Bob's dream they are extremely swift. Each jellyfish has its area of activity around it. Those areas are circles of various radii, with the jellyfish sitting in their centers. The areas of activity of two jellyfish may overlap and one area of activity may even be fully contained within another one. 
  3. Bob has a shape of a convex polygon. 
  4. Unfortunately, Bob's excess weight has made him very clumsy, and as a result he can't rotate his body while swimming. So he swims in a parallel translation pattern. However at any given moment of time he can choose any direction of his movement. 
  5. Whenever Bob swims into a jellyfish's activity area, it will immediately notice him and sting him very painfully. We assume that Bob has swum into the activity area if at some moment of time the intersection of his body with the jellyfish's activity area had a positive area (for example, if they only touch, the jellyfish does not notice Bob). 
  6. Once a jellyfish stung Bob, it happily swims away and no longer poses any threat to Bob. 



Bob wants to swim the lane to its end and get stung the least possible number of times. He will start swimming on the line y=-h, and finish on the line y=h where h = 10^{10}.

Input

The first line contains two integers n and w (3 ≤ n ≤ 200, 1 ≤ w ≤ 30000) — the number of vertices in the polygon that constitutes the Bob's shape and the width of the swimming pool lane.

Each of the next n lines contains two integers x_i and y_i (0 ≤ x_i ≤ w, 0 ≤ y_i ≤ 30000) — the coordinates of corresponding vertex of the polygon. The vertices in the polygon are given in counterclockwise order. It is guaranteed that the given polygon is strictly convex.

The next line contains an only integer m (0 ≤ m ≤ 200) — the number of the jellyfish in the pool.

Each of the next m lines contains three integers (x_i, y_i, r_i (0 ≤ x_i ≤ w, 0 ≤ y_i ≤ 30000, 1 ≤ r_i ≤ 30000) — coordinates of the i-th jellyfish in the pool and the radius of her activity. It is guaranteed, that no two jellyfish are located in the same point.

Output

Output a single integer — the least possible number of jellyfish that will sting Bob.

Examples

Input

4 4
0 0
2 0
2 2
0 2
3
1 1 1
3 5 1
1 9 1


Output

0


Input

4 6
0 0
3 0
3 3
0 3
3
1 0 1
4 2 2
3 6 1


Output

2


Input

4 2
0 0
1 0
1 1
0 1
2
1 1 1
1 3 1


Output

2

Note

Visualization of the possible solutions to the first and the second sample test cases are below:

<image> <image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 205, M = N * 2;
struct Point {
  int x, y;
} a[N * N], aa[N * N], vv;
inline Point operator-(const Point &a, const Point &b) {
  return {a.x - b.x, a.y - b.y};
}
inline ll operator^(const Point &a, const Point &b) {
  return a.x * 1ll * b.y - a.y * 1ll * b.x;
}
struct Circle {
  int x, y, r;
} c[N];
Point operator-(const Circle &a, const Circle &b) {
  return {a.x - b.x, a.y - b.y};
}
int g[M][M], h[M], d[M], n, w, m, p[M], ww[M], lst[M], stk1[N * N], top1,
    stk2[N * N], top2;
ll dis(Point a, Point b) {
  return ll(a.x - b.x) * (a.x - b.x) + ll(a.y - b.y) * (a.y - b.y);
}
ld get_dis(Point a, Point b, Point c) {
  Point tt;
  tt.x = -(b - a).y;
  tt.y = (b - a).x;
  ll aa = (a - c) ^ tt, bb = (b - c) ^ tt;
  ld ret = 0;
  if ((aa >= 0 && bb >= 0) || (aa <= 0 && bb <= 0))
    ret = min(dis(a, c), dis(b, c)) * 1.0L * dis(a, b);
  else
    aa = (a - c) ^ (b - c), ret = aa * 1.0L * aa;
  return ret;
}
bool fl;
int rr, idx;
bool check(int x, int y) {
  vv = c[x] - c[y];
  rr = c[x].r + c[y].r;
  fl = 1;
  for (int i = 1; i <= idx; i++)
    if (((a[i] - vv) ^ (a[i + 1] - vv)) > 0) {
      fl = 0;
      break;
    }
  if (fl) return 1;
  fl = 1;
  for (int i = 1; i <= idx; i++)
    if (((a[i] - vv) ^ (a[i + 1] - vv)) < 0) {
      fl = 0;
      break;
    }
  if (fl) return 1;
  ld aa = rr * 1ll * rr;
  for (int i = 1; i <= idx; i++)
    if (get_dis(a[i], a[i + 1], vv) + 0.5 < aa * dis(a[i], a[i + 1])) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> w;
  int mx = -1, mn = INT_MAX >> 2;
  for (int i = 1; i <= n; i++)
    cin >> a[i].x >> a[i].y, mx = max(a[i].x, mx), mn = min(a[i].x, mn);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> c[i].x >> c[i].y >> c[i].r;
    if (c[i].x - c[i].r < mx - mn) g[1][i + 1] = INT_MAX >> 2;
    if (w - c[i].x - c[i].r < mx - mn) g[i + m + 1][m + m + 2] = INT_MAX >> 2;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) aa[++idx] = a[i] - a[j];
  sort(aa + 1, aa + idx + 1,
       [](Point a, Point b) { return a.x < b.x || (a.x == b.x && a.y < b.y); });
  stk1[++top1] = stk2[++top2] = 1;
  for (int i = 2; i <= idx; i++) {
    while (top1 > 1 && ((aa[stk1[top1]] - aa[stk1[top1 - 1]]) ^
                        (aa[i] - aa[stk1[top1]])) >= 0)
      --top1;
    while (top2 > 1 && ((aa[stk2[top2]] - aa[stk2[top2 - 1]]) ^
                        (aa[i] - aa[stk2[top2]])) <= 0)
      --top2;
    stk1[++top1] = stk2[++top2] = i;
  }
  idx = 0;
  for (int i = 1; i <= top1; i++) a[++idx] = aa[stk1[i]];
  for (int i = top2 - 1; i > 1; --i) a[++idx] = aa[stk2[i]];
  a[idx + 1] = a[1];
  for (int i = 1; i <= m; i++) g[i + 1][i + m + 1] = 1;
  for (int i = 1; i < m; i++)
    for (int j = i + 1; j <= m; j++)
      if (check(i, j)) g[i + m + 1][j + 1] = g[j + m + 1][i + 1] = INT_MAX >> 2;
  n = m + m + 2;
  h[0] = n;
  for (int i = 1; i <= n; i++) p[i] = 1;
  int ans = 0, cur = INT_MAX >> 2, i = 1;
  while (d[1] < n) {
    ww[i] = cur;
    fl = 0;
    for (int j = p[i]; j <= n; j++)
      if (d[j] == d[i] - 1 && g[i][j] > 0) {
        lst[j] = i;
        fl = 1;
        cur = min(cur, g[i][j]);
        p[i] = j;
        i = j;
        if (i == n) {
          while (i > 1) g[i][lst[i]] += cur, g[lst[i]][i] -= cur, i = lst[i];
          ans += cur;
          cur = INT_MAX >> 2;
        }
        break;
      }
    if (fl) continue;
    mn = n - 1;
    int tmp = -1;
    for (int j = 1; j <= n; j++)
      if (g[i][j] && d[j] < mn) mn = d[j], tmp = j;
    p[i] = tmp;
    --h[d[i]];
    if (!h[d[i]]) break;
    d[i] = mn + 1;
    ++h[d[i]];
    if (i != 1) i = lst[i], cur = ww[i];
  }
  cout << ans << endl;
  return 0;
}