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;
struct point {
  long long x, y;
};
struct cir {
  long long x, y, r;
};
point p[2100], q[2100], cur[2100 * 2];
cir C[2100];
long long MN, MX;
int n, m, cnt = 2, s = 1, t = 2, edge, head[4100], nxt[1000000], a[1000000],
          r[1000000], dl[4100], level[4100], cur_head[4100], id[2100][2];
long long dis(point a) { return a.x * a.x + a.y * a.y; }
long long dot(point a, point b) { return a.x * b.x + a.y * b.y; }
long long cross(point a, point b) { return a.x * b.y - a.y * b.x; }
point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; }
point operator-(point a, point b) { return (point){a.x - b.x, a.y - b.y}; }
void create(int u, int v, int rest) {
  edge++;
  a[edge] = v;
  nxt[edge] = head[u];
  head[u] = edge;
  r[edge] = rest;
}
bool cmp(point a, point b) {
  if (a.x > 0 && b.x < 0) return true;
  if (a.x < 0 && b.x > 0) return false;
  return cross(a, b) >= 0;
}
void get_cur() {
  int c1 = 1, c2 = 1, now = 1;
  q[n + 1] = q[1];
  p[n + 1] = p[1];
  cur[1] = q[1];
  while (c1 != n + 1 || c2 != n + 1) {
    if (c1 == n + 1) {
      cur[now + 1] = cur[now] + (q[c2 + 1] - q[c2]);
      c2++;
    } else if (c2 == n + 1) {
      cur[now + 1] = cur[now] + (p[c1 + 1] - p[c1]);
      c1++;
    } else if (cmp(p[c1 + 1] - p[c1], q[c2 + 1] - q[c2])) {
      cur[now + 1] = cur[now] + (p[c1 + 1] - p[c1]);
      c1++;
    } else {
      cur[now + 1] = cur[now] + (q[c2 + 1] - q[c2]);
      c2++;
    }
    now++;
  }
  m = now;
  MN = MX = cur[1].x;
  for (int i = 2; i <= m; i++) MX = max(MX, cur[i].x);
}
long double get_dis(point x) {
  long double res = 1e18;
  int flag = 1;
  for (int i = 1; i <= m - 1; i++) {
    res = min(res, (long double)sqrt(dis(x - cur[i])));
    if (cross(cur[i + 1] - cur[i], x - cur[i]) < 0) flag = 0;
    long long t1 = dot(cur[i + 1] - cur[i], x - cur[i]),
              t2 = dis(cur[i + 1] - cur[i]);
    if (t1 >= 0 && t1 <= t2) {
      long double now = sqrt(dis(x - cur[i]) - ((long double)t1 / t2 * t1));
      res = min(res, now);
    }
  }
  if (flag) return -1;
  return res;
}
bool check(int x, int y) {
  long double tmp = get_dis((point){C[y].x - C[x].x, C[y].y - C[x].y}),
              need = C[x].r + C[y].r;
  return tmp < need;
}
void build() {
  int lef = 1, righ = 1;
  dl[1] = s;
  for (int i = 1; i <= cnt; i++) {
    level[i] = 0;
    cur_head[i] = head[i];
  }
  level[s] = 1;
  while (lef <= righ) {
    int u = dl[lef];
    for (int i = head[u]; i; i = nxt[i]) {
      int v = a[i];
      if (r[i] && level[v] == 0) {
        level[v] = level[u] + 1;
        dl[++righ] = v;
      }
    }
    lef++;
  }
}
int dinic(int u, int flow) {
  if (u == t) return flow;
  int ans = 0;
  for (int i = cur_head[u]; i; i = nxt[i]) {
    int v = a[i];
    cur_head[u] = i;
    if (r[i] && level[v] == level[u] + 1) {
      int low = dinic(v, min(flow, r[i]));
      ans += low;
      flow -= low;
      r[i] -= low;
      if (i % 2)
        r[i + 1] += low;
      else
        r[i - 1] += low;
      if (flow == 0) return ans;
    }
  }
  if (ans == 0) level[u] = -1;
  return ans;
}
int main() {
  int w, ch = 1;
  scanf("%d%d", &n, &w);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &p[i].x, &p[i].y);
    p[i + n] = p[i];
  }
  for (int i = 2; i <= n; i++)
    if (p[i].x < p[ch].x || p[i].x == p[ch].x && p[i].y < p[ch].y) ch = i;
  for (int i = 1; i <= n; i++) {
    p[i] = p[ch + i - 1];
    q[i].x = -p[i].x;
    q[i].y = -p[i].y;
    q[i + n] = q[i];
  }
  point tmp = q[1];
  ch = 1;
  for (int i = 2; i <= n; i++)
    if (q[i].x < q[ch].x || q[i].x == q[ch].x && q[i].y < q[ch].y) ch = i;
  for (int i = 1; i <= n; i++) {
    q[i] = q[ch + i - 1];
    q[i].x -= tmp.x;
    q[i].y -= tmp.y;
  }
  get_cur();
  int tot;
  scanf("%d", &tot);
  for (int i = 1; i <= tot; i++) {
    scanf("%I64d%I64d%I64d", &C[i].x, &C[i].y, &C[i].r);
    id[i][0] = ++cnt;
    id[i][1] = ++cnt;
    create(cnt - 1, cnt, 1);
    create(cnt, cnt - 1, 0);
    if (MN < -C[i].x + C[i].r) {
      create(s, id[i][0], 2147483647);
      create(id[i][0], s, 0);
    }
    if (MX > w - C[i].x - C[i].r) {
      create(id[i][1], t, 2147483647);
      create(t, id[i][1], 0);
    }
  }
  for (int i = 1; i <= tot; i++)
    for (int j = i + 1; j <= tot; j++)
      if (check(i, j)) {
        create(id[i][1], id[j][0], 2147483647);
        create(id[j][0], id[i][1], 0);
        create(id[j][1], id[i][0], 2147483647);
        create(id[i][0], id[j][1], 0);
      }
  int res = 0;
  build();
  while (level[t]) {
    res += dinic(s, 2147483647);
    build();
  }
  printf("%d\n", res);
  return 0;
}