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;
int const N = 200;
int r[N], n, w, m;
struct P {
  int x, y;
  P(int a = 0, int b = 0) : x(a), y(b) {}
  void sc() { scanf("%d%d", &x, &y); }
  P operator-(P const &o) const { return P(x - o.x, y - o.y); }
  P operator+(P const &o) const { return P(x + o.x, y + o.y); }
  double ang() const { return atan2(y, x); }
  bool operator<(P const &o) const { return ang() < o.ang(); }
  P operator-() { return P(-x, -y); }
  long long L() const { return (long long)x * x + (long long)y * y; }
  long long operator*(P const &o) const {
    return (long long)x * o.x + (long long)y * o.y;
  }
  long long operator|(P const &o) const {
    return (long long)x * o.y - (long long)y * o.x;
  }
} g[N];
vector<P> v;
void ad(vector<P> &v, P &o, vector<P> const &a) {
  int mn = 0;
  for (int i = 1; i < (int)(a.size()); ++i)
    if (a[i].y > a[mn].y || a[i].y == a[mn].y && a[i].x < a[mn].x) mn = i;
  o = o + a[mn];
  for (int i = mn; i < (int)(a.size() - 1); ++i) v.push_back(a[i + 1] - a[i]);
  v.push_back(a[0] - a.back());
  for (int i = 0; i < (int)(mn); ++i) v.push_back(a[i + 1] - a[i]);
}
vector<P> J(vector<P> const &a, vector<P> const &b) {
  vector<P> v;
  P o;
  ad(v, o, a);
  ad(v, o, b);
  inplace_merge(v.begin(), v.begin() + a.size(), v.end());
  P t = v[0];
  v[0] = o;
  for (int i = 1; i < (int)(v.size()); ++i) {
    P tt = v[i];
    v[i] = t + v[i - 1];
    t = tt;
  }
  return v;
}
unsigned long long ds(P const &a, P const &b, P const &c) {
  if ((a - b) * (c - b) < 0 || (b - a) * (c - a) < 0) return 1e18;
  long long z = a - b | c - b;
  return (unsigned long long)z * z / (a - b).L();
}
bool sad(int a, int b) {
  P p = g[a] - g[b];
  int rr = r[a] + r[b];
  for (int i = 0; i < (int)(v.size()); ++i)
    if ((p - v[i]).L() < (long long)rr * rr) return true;
  for (int i = 0; i < (int)(v.size()); ++i)
    if (ds(v[i], v[i + 1 == v.size() ? 0 : i + 1], p) <
        (unsigned long long)rr * rr)
      return true;
  bool in = true;
  for (int i = 0; i < (int)(v.size()); ++i)
    if ((v[i + 1 == v.size() ? 0 : i + 1] - v[i] | p - v[i]) < 0) {
      in = false;
      break;
    }
  return in;
}
namespace MF {
int const N = 402, M = 1000000;
int E, Pa[N], VIS[N], VS, SR, TR;
vector<int> G[N];
pair<int, int> Ed[M];
bool path(int v = SR) {
  if (v == TR) return true;
  VIS[v] = VS;
  for (int i = 0; i < (int)(G[v].size()); ++i) {
    pair<int, int> &e = Ed[G[v][i]];
    if (e.second == 0) continue;
    if (VIS[e.first] != VS && path(e.first)) {
      Pa[e.first] = G[v][i];
      return true;
    }
  }
  return false;
}
int fix() {
  int an = 2e9, v = TR;
  while (v != SR) {
    int e = Pa[v];
    an = min(an, Ed[e].second);
    v = Ed[e ^ 1].first;
  }
  v = TR;
  while (v != SR) {
    int e = Pa[v];
    Ed[e].second -= an;
    Ed[e ^ 1].second += an;
    v = Ed[e ^ 1].first;
  }
  return an;
}
inline int MF(int a, int b) {
  SR = a, TR = b;
  int an = 0;
  ++VS;
  while (path()) an += fix(), ++VS;
  return an;
}
inline void aded(int a, int b, int w1 = 1, int w2 = 0) {
  Ed[E] = make_pair(b, w1);
  Ed[E + 1] = make_pair(a, w2);
  G[a].push_back(E++);
  G[b].push_back(E++);
}
inline void CL() {
  E = 0;
  for (int i = 0; i < (int)(N); ++i) G[i].clear();
}
}  // namespace MF
int main() {
  scanf("%d%d", &n, &w);
  v.resize(n);
  for (int i = 0; i < (int)(n); ++i) v[i].sc();
  int mnx = 1e9, mxx = -1e9;
  for (int i = 0; i < (int)(n); ++i) {
    mnx = min(mnx, v[i].x);
    mxx = max(mxx, v[i].x);
  }
  vector<P> u = v;
  for (int i = 0; i < (int)(n); ++i) u[i] = -u[i];
  v = J(v, u);
  scanf("%d", &m);
  for (int i = 0; i < (int)(m); ++i) {
    g[i].sc();
    scanf("%d", r + i);
  }
  for (int i = 0; i < (int)(m); ++i) MF::aded(i << 1, i << 1 | 1);
  for (int i = 0; i < (int)(m); ++i)
    for (int j = i + 1; j < (int)(m); ++j)
      if (sad(i, j)) {
        MF::aded(i << 1 | 1, j << 1, 1e9);
        MF::aded(j << 1 | 1, i << 1, 1e9);
      }
  for (int i = 0; i < (int)(m); ++i)
    if (g[i].x - r[i] < mxx - mnx) MF::aded(m << 1, i << 1, 1e9);
  for (int i = 0; i < (int)(m); ++i)
    if (g[i].x + r[i] > w - (mxx - mnx)) MF::aded(i << 1 | 1, m << 1 | 1, 1e9);
  printf("%d\n", MF::MF(m << 1, m << 1 | 1));
  return 0;
}