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>
#pragma GCC optimize "-O3"
using namespace std;
const int inf = 1e9 + 7;
const int N = 201;
struct Dinitz {
  int n, s, t;
  struct Edge {
    int v, c, f;
    Edge(int v = 0, int c = 0) : v(v), c(c), f(0) {}
  };
  vector<vector<int> > g;
  vector<int> d, p;
  vector<Edge> E;
  Dinitz(int _n = 0, int _s = 0, int _t = 0) : n(_n), s(_s), t(_t) {
    g.assign(n + 5, {});
    E.clear();
  }
  void addEdge(int u, int v, int c) {
    g[u].push_back(E.size());
    E.push_back({v, c});
    g[v].push_back(E.size());
    E.push_back({u, 0});
  }
  bool bfs() {
    d.assign(n + 5, -1);
    p.assign(n + 5, 0);
    queue<int> q;
    q.push(s);
    d[s] = 0;
    while (q.size()) {
      int u = q.front();
      q.pop();
      for (int i : g[u]) {
        int v = E[i].v;
        if (d[v] == -1 && E[i].c > E[i].f) {
          d[v] = d[u] + 1;
          q.push(v);
        }
      }
    }
    return d[t] != -1;
  }
  int dfs(int u, int flow) {
    if (u == t || flow == 0) return flow;
    for (int &i = p[u]; i < g[u].size(); ++i) {
      int j = g[u][i], v = E[j].v;
      if (d[v] != d[u] + 1) continue;
      if (E[j].c <= E[j].f) continue;
      int nxt = dfs(v, min(flow, E[j].c - E[j].f));
      if (nxt) {
        E[j].f += nxt;
        E[j ^ 1].f -= nxt;
        return nxt;
      }
    }
    return 0;
  }
  int calc() {
    while (bfs())
      while (dfs(s, inf))
        ;
    int res = 0;
    for (int i : g[s]) res += E[i].f;
    return res;
  }
} dn;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
long long sqr(pair<int, int> a) {
  return 1ll * a.first * a.first + 1ll * a.second * a.second;
}
long long cro(pair<int, int> p, pair<int, int> q) {
  return 1ll * p.first * q.second - 1ll * p.second * q.first;
}
long long sca(pair<int, int> p, pair<int, int> q) {
  return 1ll * p.first * q.first + 1ll * p.second * q.second;
}
vector<pair<int, int> > flip(vector<pair<int, int> > a) {
  int p = min_element(a.begin(), a.end()) - a.begin(), n = a.size();
  vector<pair<int, int> > b;
  for (int i = 0; i < n; ++i) b.push_back(a[(p + i) % n]);
  return b;
}
vector<pair<int, int> > Msum(vector<pair<int, int> > a,
                             vector<pair<int, int> > b) {
  a = flip(a);
  b = flip(b);
  vector<pair<int, int> > L(a.size()), R(b.size());
  for (int i = 0; i < a.size(); ++i) L[i] = a[(i + 1) % a.size()] - a[i];
  for (int i = 0; i < b.size(); ++i) R[i] = b[(i + 1) % b.size()] - b[i];
  vector<pair<int, int> > res = {a[0] + b[0]};
  int i = 0, j = 0;
  while (i < a.size() && j < b.size())
    res.push_back(res.back() + (cro(L[i], R[j]) >= 0 ? L[i++] : R[j++]));
  while (i < a.size()) res.push_back(res.back() + L[i++]);
  while (j < b.size()) res.push_back(res.back() + R[j++]);
  return res;
}
bool isect(vector<pair<int, int> > P, pair<int, int> Q, int r) {
  int n = P.size();
  long long sum1 = 0;
  long long sum2 = 0;
  for (int i = 0; i < n; ++i) {
    if (sqr(P[i] - Q) < 1ll * r * r) return 1;
    pair<int, int> a = P[i], b = P[(i + 1) % n];
    sum1 += abs(cro(Q - a, Q - b));
    sum2 += cro(a, b);
    if (sca(a - b, Q - b) <= 0) continue;
    if (sca(b - a, Q - a) <= 0) continue;
    long long area = abs(cro(Q - a, Q - b));
    if (area * area < sqr(a - b) * r * r) return 1;
  }
  return sum1 == abs(sum2);
}
int n, m, W;
pair<int, int> c[N];
int r[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> W;
  vector<pair<int, int> > P(n), Q(n);
  int mn = inf, mx = 0;
  for (int i = 0; i < n; ++i) {
    cin >> P[i].first >> P[i].second;
    Q[i] = pair<int, int>(0, 0) - P[i];
    mn = min(mn, P[i].first);
    mx = max(mx, P[i].first);
  }
  cin >> m;
  int S = 0, T = m + m + 1;
  dn = Dinitz(T, S, T);
  for (int i = 1; i <= m; ++i) {
    cin >> c[i].first >> c[i].second >> r[i];
    dn.addEdge(i, i + m, 1);
    if (c[i].first - r[i] - mx + mn < 0) dn.addEdge(S, i, inf);
    if (c[i].first + r[i] + mx - mn > W) dn.addEdge(i + m, T, inf);
  }
  P = Msum(P, Q);
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j < i; ++j)
      if (isect(P, c[i] - c[j], r[i] + r[j]))
        dn.addEdge(i + m, j, inf), dn.addEdge(j + m, i, inf);
  cout << dn.calc() << endl;
}