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;
const int inf = (1e9);
struct P {
  int x, y;
  P(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  P operator-(P X) { return P(x - X.x, y - X.y); }
  long long operator^(P X) { return 1ll * x * X.y - 1ll * y * X.x; }
} a[40004], A[40004], v, v1, v2;
struct C {
  int x, y, r;
  P operator-(C X) { return P(x - X.x, y - X.y); }
} c[204];
int g[404][404], h[404], d[404], n, w, m, ma, mi, p[404], ans, nw, W[404],
    la[404], sta1[40004], tp1, sta2[40004], tp2, cnt, R, mii;
bool bo;
bool cmp(P a, P b) { return a.x < b.x || a.x == b.x && a.y < b.y; }
int getmin(int a, int b) { return a < b ? a : b; }
int getmax(int a, int b) { return a > b ? a : b; }
long long getm(long long a, long long b) { return a < b ? a : b; }
long long dis(P a, P b) {
  return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y);
}
long double getdis(P a, P b, P c) {
  P t;
  t.x = -((b - a).y);
  t.y = (b - a).x;
  long long A = ((a - c) ^ t), B = ((b - c) ^ t);
  long double ans;
  if (A >= 0 && B >= 0 || A <= 0 && B <= 0)
    ans = getm(dis(a, c), dis(b, c)), ans = ans * dis(a, b);
  else {
    A = ((a - c) ^ (b - c));
    if (A < 0) A = -A;
    ans = A, ans = ans * A;
  }
  return ans;
}
bool check(int x, int y) {
  v = c[x] - c[y];
  R = c[x].r + c[y].r;
  bo = 1;
  for (int i = 1; i <= cnt; i++)
    if (((a[i] - v) ^ (a[i + 1] - v)) > 0) {
      bo = 0;
      break;
    }
  if (bo) return 1;
  bo = 1;
  for (int i = 1; i <= cnt; i++)
    if (((a[i] - v) ^ (a[i + 1] - v)) < 0) {
      bo = 0;
      break;
    }
  if (bo) return 1;
  long double A = 1ll * R * R;
  for (int i = 1; i <= cnt; i++)
    if (getdis(a[i], a[i + 1], v) + 0.5 < A * dis(a[i], a[i + 1])) return 1;
  return 0;
}
int main() {
  memset(g, 0, sizeof(g));
  scanf("%d%d", &n, &w);
  ma = -1;
  mi = inf;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y), ma = getmax(a[i].x, ma),
                                     mi = getmin(a[i].x, mi);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &c[i].x, &c[i].y, &c[i].r);
    if (c[i].x - c[i].r < ma - mi) g[1][i + 1] = inf;
    if (w - c[i].x - c[i].r < ma - mi) g[i + m + 1][m + m + 2] = inf;
  }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) A[++cnt] = a[i] - a[j];
  sort(A + 1, A + 1 + cnt, cmp);
  tp1 = tp2 = 0;
  sta1[++tp1] = 1;
  sta2[++tp2] = 1;
  for (int i = 2; i <= cnt; i++) {
    while (tp1 > 1 &&
           ((A[sta1[tp1]] - A[sta1[tp1 - 1]]) ^ (A[i] - A[sta1[tp1]])) >= 0)
      tp1--;
    sta1[++tp1] = i;
    while (tp2 > 1 &&
           ((A[sta2[tp2]] - A[sta2[tp2 - 1]]) ^ (A[i] - A[sta2[tp2]])) <= 0)
      tp2--;
    sta2[++tp2] = i;
  }
  cnt = 0;
  for (int i = 1; i <= tp1; i++) a[++cnt] = A[sta1[i]];
  for (int i = tp2 - 1; i > 1; i--) a[++cnt] = A[sta2[i]];
  a[cnt + 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] = inf;
  n = m + m + 2;
  h[0] = n;
  for (int i = 1; i <= n; i++) p[i] = 1;
  memset(d, 0, sizeof(d));
  ans = 0;
  nw = inf;
  int i = 1;
  while (d[1] < n) {
    W[i] = nw;
    bo = 0;
    for (int j = p[i]; j <= n; j++)
      if (d[j] == d[i] - 1 && g[i][j] > 0) {
        la[j] = i;
        bo = 1;
        nw = getmin(nw, g[i][j]);
        p[i] = j;
        i = j;
        if (i == n) {
          while (i != 1) g[i][la[i]] += nw, g[la[i]][i] -= nw, i = la[i];
          ans += nw;
          nw = inf;
        }
        break;
      }
    if (bo) continue;
    mi = n - 1;
    for (int j = 1; j <= n; j++)
      if (g[i][j] && d[j] < mi) mi = d[j], mii = j;
    p[i] = mii;
    h[d[i]]--;
    if (!h[d[i]]) break;
    d[i] = mi + 1;
    h[d[i]]++;
    if (i != 1) i = la[i], nw = W[i];
  }
  printf("%d\n", ans);
  return 0;
}