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 P {
  int x, y;
  P() {}
  P(int _x, int _y) {
    x = _x;
    y = _y;
  }
  P operator+(const P &a) const { return P(x + a.x, y + a.y); }
  P operator-(const P &a) const { return P(x - a.x, y - a.y); }
  long long operator*(const P &a) const {
    return 1ll * x * a.y - 1ll * y * a.x;
  }
  long long operator^(const P &a) const {
    return 1ll * x * a.x + 1ll * y * a.y;
  }
  bool operator<(const P &a) const { return x == a.x ? y < a.y : x < a.x; }
};
long long Dis(P x, P y) { return (x - y) ^ (x - y); }
vector<P> init(vector<P> p) {
  vector<P> ans;
  int pos = min_element(p.begin(), p.end()) - p.begin();
  for (int i = (int)(0); i <= (int)(p.size() - 1); i++)
    ans.push_back(p[(i + pos) % p.size()]);
  return ans;
}
vector<P> Mincowski(vector<P> a, vector<P> b) {
  a = init(a);
  b = init(b);
  int sza = a.size(), szb = b.size();
  vector<P> ans, A(sza), B(szb);
  for (int i = (int)(0); i <= (int)(sza - 1); i++)
    A[i] = a[(i + 1) % sza] - a[i];
  for (int i = (int)(0); i <= (int)(szb - 1); i++)
    B[i] = b[(i + 1) % szb] - b[i];
  int i = 0, j = 0;
  ans.push_back(a[0] + b[0]);
  for (; i < sza || j < szb;)
    if (j == szb)
      ans.push_back(ans.back() + A[i++]);
    else if (i == sza)
      ans.push_back(ans.back() + B[j++]);
    else
      ans.push_back(ans.back() + (A[i] * B[j] >= 0 ? A[i++] : B[j++]));
  ans.pop_back();
  return ans;
}
bool online(P p, P l, P r) {
  return ((p - l) * (p - r)) == 0 && ((p - l) ^ (p - r)) <= 0;
}
bool check(P p, long long R, vector<P> q) {
  for (auto i : q)
    if (Dis(i, p) < R * R) return 1;
  bool flag = 1;
  for (int i = (int)(0); i <= (int)(q.size() - 1); i++) {
    P l = q[i], r = q[(i + 1) % q.size()];
    if (online(p, l, r)) return 1;
    if (((p - l) ^ (r - l)) > 0 && ((p - r) ^ (l - r)) > 0) {
      long long x = abs((p - l) * (r - l));
      if (x * x < R * R * Dis(l, r)) return 1;
    }
    flag &= ((p - l) * (r - l) <= 0);
  }
  return flag;
}
const int N = 405;
struct edge {
  int to, next, f;
} e[N * N];
int head[N], dis[N], q[N];
int n, m, W, S, T, tot = 1;
void add(int x, int y, int v) {
  e[++tot] = (edge){y, head[x], v};
  head[x] = tot;
  e[++tot] = (edge){x, head[y], 0};
  head[y] = tot;
}
bool bfs() {
  for (int i = (int)(1); i <= (int)(T); i++) dis[i] = -1;
  int h = 0, t = 1;
  q[1] = S;
  dis[S] = 0;
  while (h != t) {
    int x = q[++h];
    for (int i = head[x]; i; i = e[i].next)
      if (dis[e[i].to] == -1 && e[i].f) {
        dis[e[i].to] = dis[x] + 1;
        if (e[i].to == T) return 1;
        q[++t] = e[i].to;
      }
  }
  return 0;
}
int dfs(int x, int flow) {
  if (x == T) return flow;
  int rest = flow;
  for (int i = head[x]; i && rest; i = e[i].next)
    if (dis[e[i].to] == dis[x] + 1 && e[i].f) {
      int k = dfs(e[i].to, min(rest, e[i].f));
      e[i].f -= k;
      e[i ^ 1].f += k;
      rest -= k;
    }
  if (rest) dis[x] = -1;
  return flow - rest;
}
int main() {
  scanf("%d%d", &n, &W);
  vector<P> p(n), q(n);
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    p[i] = P(x, y);
    q[i] = P(-x, -y);
  }
  int mn = p[0].x, mx = p[0].x;
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    mn = min(mn, p[i].x);
    mx = max(mx, p[i].x);
  }
  p = Mincowski(p, q);
  scanf("%d", &m);
  vector<P> o(m + 1);
  vector<int> R(m + 1);
  for (int i = (int)(1); i <= (int)(m); i++)
    scanf("%d%d%d", &o[i].x, &o[i].y, &R[i]);
  S = m * 2 + 1;
  T = S + 1;
  for (int i = (int)(1); i <= (int)(m); i++) {
    add(i * 2 - 1, i * 2, 1);
    if (mx - mn > o[i].x - R[i]) add(S, 2 * i - 1, 1 << 30);
    if (mx - mn > W - o[i].x - R[i]) add(2 * i, T, 1 << 30);
  }
  for (int i = (int)(1); i <= (int)(m); i++)
    for (int j = (int)(i + 1); j <= (int)(m); j++)
      if (check(o[i] - o[j], R[i] + R[j], p)) {
        add(i * 2, j * 2 - 1, 1 << 30);
        add(j * 2, i * 2 - 1, 1 << 30);
      }
  int ans = 0;
  for (; bfs(); ans += dfs(S, 1 << 30))
    ;
  printf("%d\n", ans);
}