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;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
long long n, m, w, L, R, p[410], d[410], q[410], cur[410], t = -1, ans;
struct point {
  long long x, y;
  point operator+(const point &a) const { return (point){x + a.x, y + a.y}; }
  point operator-(const point &a) const { return (point){x - a.x, y - a.y}; }
  long long operator*(const point &a) const { return x * a.y - y * a.x; }
  long long operator^(const point &a) const { return x * a.x + y * a.y; }
} a[410], u[410 << 1], v[410 << 1], r[410 << 1], Left;
struct circle {
  point o;
  long long r;
} b[410];
struct data {
  long long to, nxt, cap, flow;
} edge[410 * 410 << 3];
void addedge(long long x, long long y, long long z) {
  t++;
  edge[t].to = y, edge[t].nxt = p[x], edge[t].cap = z, p[x] = t;
  t++;
  edge[t].to = x, edge[t].nxt = p[y], edge[t].cap = 0, p[y] = t;
}
bool bfs() {
  memset(d, 255, sizeof(d));
  d[0] = 0;
  long long head = 0, tail = 1;
  q[1] = 0;
  do {
    long long x = q[++head];
    for (long long i = p[x]; ~i; i = edge[i].nxt)
      if (d[edge[i].to] == -1 && edge[i].flow < edge[i].cap) {
        d[edge[i].to] = d[x] + 1;
        q[++tail] = edge[i].to;
      }
  } while (head < tail);
  return ~d[401];
}
long long work(long long k, long long f) {
  if (k == 401) return f;
  long long used = 0;
  for (long long i = cur[k]; ~i; i = edge[i].nxt)
    if (d[k] + 1 == d[edge[i].to]) {
      long long w = work(edge[i].to, min(f - used, edge[i].cap - edge[i].flow));
      edge[i].flow += w, edge[i ^ 1].flow -= w;
      if (edge[i].flow < edge[i].cap) cur[k] = i;
      used += w;
      if (used == f) return f;
    }
  if (used == 0) d[k] = -1;
  return used;
}
void dinic() {
  while (bfs()) {
    memcpy(cur, p, sizeof(p));
    ans += work(0, 410);
  }
}
long long len(point a) { return a ^ a; }
bool isin(point *r, long long n) {
  for (long long i = 2; i <= n; i++)
    if ((r[i] - r[i - 1]) * ((point){0, 0} - r[i - 1]) < 0) return 0;
  return 1;
}
bool check(point a, point b, long long r) {
  if (((b - a) ^ ((point){0, 0} - a)) > 0 &&
      ((a - b) ^ ((point){0, 0} - b)) > 0)
    return ((b - a) * ((point){0, 0} - a)) * ((b - a) * ((point){0, 0} - a)) <
           r * r * len(a - b);
  else
    return 0;
}
long long merge(point *u, point *v) {
  r[1] = u[1] + v[1];
  long long tail = 1;
  long long i = 1, j = 1;
  while (i <= n || j <= n) {
    if (i > n)
      j++;
    else if (j > n)
      i++;
    else if ((u[i] + v[j + 1] - r[tail]) * (u[i + 1] + v[j] - r[tail]) > 0)
      j++;
    else
      i++;
    point t = u[i] + v[j];
    while (tail > 1 && (t - r[tail - 1]) * (r[tail] - r[tail - 1]) > 0) tail--;
    r[++tail] = t;
  }
  return tail;
}
bool cross(circle x, circle y) {
  for (long long i = 1; i <= n; i++) u[i] = x.o - (a[i] - Left);
  for (long long i = 1; i <= n; i++) v[i] = (a[i] - Left) - y.o;
  long long u_first = 1;
  for (long long i = 2; i <= n; i++)
    if (u[i].x < u[u_first].x ||
        u[i].x == u[u_first].x && u[i].y < u[u_first].y)
      u_first = i;
  long long v_first = 1;
  for (long long i = 2; i <= n; i++)
    if (v[i].x < v[v_first].x ||
        v[i].x == v[v_first].x && v[i].y < v[v_first].y)
      v_first = i;
  for (long long i = n + 1; i <= 2 * n; i++) u[i] = u[i - n], v[i] = v[i - n];
  long long tail = merge(u + u_first - 1, v + v_first - 1);
  if (isin(r, tail)) return 1;
  for (long long i = 1; i <= tail; i++)
    if (len(r[i]) < (x.r + y.r) * (x.r + y.r)) return 1;
  for (long long i = 1; i < tail; i++)
    if (check(r[i], r[i + 1], x.r + y.r)) return 1;
  return 0;
}
signed main() {
  n = read(), w = read();
  memset(p, 255, sizeof(p));
  Left = (point){410 * 410, 410 * 410};
  L = 410 * 410;
  R = -410 * 410;
  for (long long i = 1; i <= n; i++) {
    a[i].x = read(), a[i].y = read();
    L = min(L, a[i].x), R = max(R, a[i].x);
    if (a[i].x < Left.x) Left = a[i];
  }
  m = read();
  for (long long i = 1; i <= m; i++)
    b[i].o.x = read(), b[i].o.y = read(), b[i].r = read();
  for (long long i = 1; i <= m; i++)
    for (long long j = i + 1; j <= m; j++)
      if (cross(b[i], b[j]))
        addedge((i * 2), (j * 2 - 1), 1), addedge((j * 2), (i * 2 - 1), 1);
  for (long long i = 1; i <= m; i++) {
    if (b[i].o.x - (R - L) - b[i].r < 0) addedge(0, (i * 2 - 1), 1);
    if (b[i].o.x + (R - L) + b[i].r > w) addedge((i * 2), 401, 1);
  }
  for (long long i = 1; i <= m; i++) addedge((i * 2 - 1), (i * 2), 1);
  dinic();
  cout << ans;
  return 0;
}