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 {
  long long x, y;
  P() {}
  P(long long _x, long long _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 ? x < a.x : y < a.y; }
};
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> merge(vector<P> p, vector<P> q) {
  p = init(p);
  q = init(q);
  int szp = p.size(), szq = q.size();
  vector<P> d1(szp), d2(szq);
  for (int i = (int)(0); i <= (int)(szp - 1); i++)
    d1[i] = p[(i + 1) % szp] - p[i];
  for (int i = (int)(0); i <= (int)(szq - 1); i++)
    d2[i] = q[(i + 1) % szq] - q[i];
  vector<P> ans;
  ans.push_back(p[0] + q[0]);
  int pos1 = 0, pos2 = 0;
  for (; pos1 < szp || pos2 < szq;)
    if (pos2 == szq)
      ans.push_back(ans.back() + d1[pos1++]);
    else if (pos1 == szp)
      ans.push_back(ans.back() + d2[pos2++]);
    else
      ans.push_back(ans.back() +
                    (d2[pos2] * d1[pos1] >= 0 ? d2[pos2++] : d1[pos1++]));
  return ans;
}
bool online(P p, P l, P r) {
  return ((p - l) * (r - l)) == 0 && ((l - p) ^ (r - p)) <= 0;
}
bool check(P p, long long r, vector<P> pp) {
  for (auto i : pp)
    if (Dis(p, i) < r * r) return 1;
  for (int i = (int)(0); i <= (int)(pp.size() - 1); i++) {
    P L = pp[i], R = pp[(i + 1) % pp.size()];
    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;
    }
  }
  for (int i = (int)(0); i <= (int)(pp.size() - 1); i++)
    if (online(p, pp[i], pp[(i + 1) % pp.size()])) return 1;
  bool flag = 1;
  for (int i = (int)(0); i <= (int)(pp.size() - 1); i++)
    flag &= (((p - pp[i]) * (pp[(i + 1) % pp.size()] - pp[i])) <= 0);
  return flag;
}
const int N = 255;
struct edge {
  int to, next, f;
} e[4 * N * N];
int head[N * 2], tot = 1, S, T;
int dis[N * 2], q[N * 2];
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 t = 1;
  dis[q[1] = S] = 0;
  for (int h = (int)(1); h <= (int)(t); h++)
    for (int i = head[q[h]]; i; i = e[i].next)
      if (dis[e[i].to] == -1 && e[i].f) {
        dis[e[i].to] = dis[q[h]] + 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 k, rest = flow;
  for (int i = head[x]; i && rest; i = e[i].next)
    if (dis[e[i].to] == dis[x] + 1 && e[i].f) {
      k = dfs(e[i].to, min(flow, e[i].f));
      e[i].f -= k;
      e[i ^ 1].f += k;
      rest -= k;
    }
  if (rest) dis[x] = -1;
  return flow - rest;
}
int n, W, m;
struct circle {
  long long x, y, r;
} o[N];
int main() {
  scanf("%d%d", &n, &W);
  vector<P> p(n), q(n);
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    scanf("%lld%lld", &p[i].x, &p[i].y);
    q[i].x = -p[i].x;
    q[i].y = -p[i].y;
  }
  long long 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 = merge(p, q);
  scanf("%d", &m);
  S = 2 * m + 1;
  T = 2 * m + 2;
  for (int i = (int)(1); i <= (int)(m); i++)
    scanf("%lld%lld%lld", &o[i].x, &o[i].y, &o[i].r);
  for (int i = (int)(1); i <= (int)(m); i++) {
    add(i * 2 - 1, i * 2, 1);
    if (mx - mn > o[i].x - o[i].r) add(S, i * 2 - 1, 1 << 30);
    if (mx - mn > W - o[i].x - o[i].r) add(i * 2, T, 1 << 30);
  }
  for (int i = (int)(1); i <= (int)(m); i++)
    for (int j = (int)(i + 1); j <= (int)(m); j++)
      if (check(P(o[j].x - o[i].x, o[j].y - o[i].y), o[j].r + o[i].r, 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);
}