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 N = 210, inf = 1e9;
int n, m, w, op, ed, cnta, cntb, cnt;
struct dot {
  long long x, y;
} p[N][2], s[N * 2];
struct xint {
  pair<int, int> x;
  dot p;
} Pa[N * 2], Pb[N * 2], P[N * 2];
struct circle {
  dot s;
  long long r;
} q[N * 2];
dot operator+(dot a, dot b) { return (dot){a.x + b.x, a.y + b.y}; }
dot operator-(dot a, dot b) { return (dot){a.x - b.x, a.y - b.y}; }
long long operator^(dot a, dot b) { return a.x * b.y - a.y * b.x; }
bool operator==(dot a, dot b) { return a.x == b.x && a.y == b.y; }
long long norm(dot a) { return a.x * a.x + a.y * a.y; }
bool cmp(xint a, xint b) { return (a.p ^ b.p) > 0; }
void InsertP(xint a) {
  if (a.p.y > 0 || a.p.y == 0 && a.p.x > 0)
    Pa[++cnta] = a;
  else
    Pb[++cntb] = a;
}
void InsertS(dot a) {
  if (cnt == 0 || !(s[cnt] == a)) s[++cnt] = a;
}
void InitP(int n) {
  xint a0, a1;
  for (int i = n; i >= 1; --i)
    if (P[i].x.second == 0) {
      a0 = P[i];
      break;
    }
  for (int i = n; i >= 1; --i)
    if (P[i].x.second == 1) {
      a1 = P[i];
      break;
    }
  cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (P[i].x.second == 0) InsertS(p[a1.x.first][1] + p[P[i].x.first][0]);
    if (P[i].x.second == 1) InsertS(p[a0.x.first][0] + p[P[i].x.first][1]);
    if (P[i].x.second == 0) a0 = P[i];
    if (P[i].x.second == 1) a1 = P[i];
  }
  while (cnt > 1 && s[cnt] == s[1]) cnt--;
}
bool Check(long long r) {
  bool flag = 1;
  for (int i = 0; i <= cnt; ++i)
    if ((s[i] ^ s[i + 1]) <= 0) flag = 0;
  if (flag) return 1;
  for (int i = 0; i <= cnt; ++i) {
    long long s1 = norm(s[i]), s2 = norm(s[i + 1]);
    if (s1 < r * r || s2 < r * r) return 1;
    long long s3 = norm(s[i + 1] - s[i]);
    if (s1 > s2) swap(s1, s2);
    if (s1 + s3 > s2)
      if (1.0 * abs(s[i] ^ s[i + 1]) / sqrt(s3) < r) return 1;
  }
  return 0;
}
int Cnt, head[N * 2];
struct edge {
  int to, next, s;
} e[N * N * 2];
void add(int x, int y, int a, int b) {
  if (!(Cnt & 1)) Cnt++;
  e[++Cnt] = (edge){y, head[x], a};
  head[x] = Cnt;
  e[++Cnt] = (edge){x, head[y], b};
  head[y] = Cnt;
}
void add(int x, int y) {
  if (x == op)
    add(x, y, inf, 0);
  else
    add(x + m, y, inf, 0);
}
int dis[N * 2], qe[N * 2];
bool bfs() {
  for (int i = 1; i <= ed; ++i) dis[i] = inf;
  dis[op] = 0;
  int h = 0, t = 0;
  qe[++t] = op;
  while (h++ < t) {
    int u = qe[h];
    for (int i = head[u]; i; i = e[i].next)
      if (e[i].s > 0) {
        int v = e[i].to;
        if (dis[v] == inf) dis[v] = dis[u] + 1, qe[++t] = v;
      }
  }
  return dis[ed] < inf;
}
int dfs(int x, int flow) {
  if (x == ed) return flow;
  int res = 0;
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].s > 0 && dis[e[i].to] == dis[x] + 1) {
      int s = dfs(e[i].to, min(flow, e[i].s));
      res += s;
      flow -= s;
      e[i].s -= s;
      e[i ^ 1].s += s;
    }
  return res;
}
int dinic() {
  int ans = 0, s = 0;
  while (bfs()) {
    while (s = dfs(op, inf)) ans += s;
  }
  return ans;
}
int main() {
  cin >> n >> w;
  long long mx1 = inf, mx2 = -inf;
  for (int i = 1; i <= n; ++i) cin >> p[i][0].x >> p[i][0].y;
  for (int i = 1; i <= n; ++i)
    mx1 = min(mx1, p[i][0].x), mx2 = max(mx2, p[i][0].x);
  p[0][0] = p[n][0];
  p[n + 1][0] = p[1][0];
  for (int i = 0; i <= n + 1; ++i) p[i][1] = (dot){0, 0} - p[i][0];
  for (int i = 1; i <= n; ++i)
    InsertP((xint){make_pair(i, 0), p[i][0] - p[i - 1][0]});
  for (int i = 1; i <= n; ++i)
    InsertP((xint){make_pair(i, 1), p[i][1] - p[i - 1][1]});
  sort(Pa + 1, Pa + cnta + 1, cmp);
  sort(Pb + 1, Pb + cntb + 1, cmp);
  for (int i = 1; i <= cnta; ++i) P[++cnt] = Pa[i];
  for (int i = 1; i <= cntb; ++i) P[++cnt] = Pb[i];
  InitP(cnt);
  s[0] = s[cnt];
  s[cnt + 1] = s[1];
  cin >> m;
  for (int i = 1; i <= m; ++i) cin >> q[i].s.x >> q[i].s.y >> q[i].r;
  op = m * 2 + 1, ed = m * 2 + 2;
  for (int i = 1; i <= m; ++i) add(i, i + m, 1, 1);
  for (int i = 1; i <= m; ++i) {
    if (q[i].s.x - q[i].r - (mx2 - mx1) < 0) add(op, i);
    if (w - q[i].s.x - q[i].r - (mx2 - mx1) < 0) add(i, ed);
  }
  for (int i = 1; i <= m; ++i)
    for (int j = i + 1; j <= m; ++j) {
      circle C = (circle){q[i].s - q[j].s, q[i].r + q[j].r};
      for (int I = 0; I <= cnt + 1; ++I) s[I] = s[I] - C.s;
      if (Check(C.r)) add(i, j), add(j, i);
      for (int I = 0; I <= cnt + 1; ++I) s[I] = s[I] + C.s;
    }
  printf("%d\n", dinic());
}