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;
void wssert(bool b) {
  if (!b) {
    cout << "GARBAGE\n";
    exit(0);
  }
}
using ll = long long;
struct point {
  int x, y;
  point() : x(0), y(0) {}
  point(int x_, int y_) : x(x_), y(y_) {}
  friend std::ostream& operator<<(std::ostream& o, const point& p) {
    return o << "(" << p.x << "," << p.y << ")";
  }
  friend std::istream& operator>>(std::istream& i, point& p) {
    return i >> p.x >> p.y;
  }
  point operator-() const { return point(-x, -y); }
  point& operator+=(const point& o) {
    x += o.x, y += o.y;
    return *this;
  }
  point& operator-=(const point& o) {
    x -= o.x, y -= o.y;
    return *this;
  }
  friend point operator+(const point& a, const point& b) {
    return point(a) += b;
  }
  friend point operator-(const point& a, const point& b) {
    return point(a) -= b;
  }
  friend bool operator==(const point& a, const point& b) {
    return a.x == b.x && a.y == b.y;
  }
  friend bool operator!=(const point& a, const point& b) {
    return a.x != b.x || a.y != b.y;
  }
  ll norm() const { return ll(x) * ll(x) + ll(y) * ll(y); }
  int quad() const {
    assert(x != 0 || y != 0);
    if (x < 0 && y <= 0) return 1;
    if (y < 0 && x >= 0) return 2;
    if (x > 0 && y >= 0) return 3;
    if (y > 0 && x <= 0) return 4;
    assert(false);
    return 0;
  }
};
bool angle_cmp(const point& a, const point& b) {
  int qa = a.quad();
  int qb = b.quad();
  if (qa != qb) return qa < qb;
  ll cross = ll(a.x) * b.y - ll(a.y) * b.x;
  if (cross != 0) return cross > 0;
  return a.norm() < b.norm();
}
const int MAXN = 300;
const int MAXM = 300;
int W;
int N;
point P[2 * MAXN];
point mink[2 * MAXN];
bool intersects(point center, ll r) {
  assert(r > 0);
  if ((P[0] - center).norm() < r * r) return true;
  int numCross = 0;
  for (int a = 0; a < N; a++) {
    point p = P[a] - center;
    point q = P[a + 1] - center;
    if (q.norm() < r * r) {
      return true;
    }
    if (abs(p.norm() - q.norm()) < (q - p).norm()) {
      ll area = abs(p.x * q.y - p.y * q.x);
      if (r * r * (q - p).norm() > area * area) {
        return true;
      }
    }
    if ((p.x > 0) != (q.x > 0)) {
      if (q.x > 0) swap(p, q);
      assert(p.x > 0);
      assert(q.x <= 0);
      ll cross = ll(q.x) * p.y - p.x * q.y;
      if (cross == 0) {
        return true;
      }
      if (cross > 0) {
        numCross++;
      }
    }
  }
  if (numCross & 1) {
    return true;
  }
  return false;
}
int M;
pair<point, int> J[MAXM];
const int MAXV = MAXM * 2;
int V;
int cap[MAXV][MAXV];
int vis[MAXV];
int flow() {
  int res = 0;
  while (true) {
    for (int i = 0; i < V; i++) {
      vis[i] = -1;
    }
    queue<int> q;
    vis[0] = 0;
    q.push(0);
    while (vis[V - 1] == -1 && !q.empty()) {
      int cur = q.front();
      q.pop();
      for (int nxt = V - 1; nxt >= 0; nxt--) {
        if (vis[nxt] != -1) continue;
        if (!cap[cur][nxt]) continue;
        vis[nxt] = cur;
        q.push(nxt);
      }
    }
    if (vis[V - 1] == -1) break;
    res++;
    for (int cur = V - 1; cur != 0; cur = vis[cur]) {
      int prv = vis[cur];
      assert(prv != -1);
      cap[prv][cur] -= 1;
      cap[cur][prv] += 1;
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  P[N] = P[0];
  cin >> M;
  for (int j = 0; j < M; j++) {
    cin >> J[j].first >> J[j].second;
  }
  for (int i = 0; i < N; i++) {
    mink[2 * i + 0] = P[i + 1] - P[i];
    mink[2 * i + 1] = P[i] - P[i + 1];
  }
  N *= 2;
  sort(mink, mink + N, angle_cmp);
  P[0] = {0, 0};
  for (int i = 0; i < N; i++) {
    P[i + 1] = P[i] + mink[i];
  }
  assert(P[N] == P[0]);
  point mid = P[0] + P[N / 2];
  assert(mid.x % 2 == 0 && mid.y % 2 == 0);
  mid.x /= 2;
  mid.y /= 2;
  for (int i = 0; i <= N; i++) {
    P[i] -= mid;
  }
  for (int i = 0; i < N / 2; i++) {
    assert(P[i] + P[i + N / 2] == point(0, 0));
  }
  V = 2 * M + 2;
  int maxX = P[0].x;
  for (int a = 0; a < N; a++) {
    maxX = max(maxX, P[a].x);
  }
  assert(maxX <= W);
  for (int j = 0; j < M; j++) {
    cap[2 * j + 1][2 * j + 2] = 1;
    if (maxX + J[j].second > J[j].first.x) {
      cap[0][2 * j + 1] = 1;
    }
    if (maxX + J[j].second > W - J[j].first.x) {
      cap[2 * j + 2][2 * M + 1] = 1;
    }
  }
  for (int j = 0; j < M; j++) {
    for (int k = j + 1; k < M; k++) {
      point p = J[j].first - J[k].first;
      ll r = J[j].second + J[k].second;
      if (intersects(p, r)) {
        cap[2 * j + 2][2 * k + 1] = 1;
        cap[2 * k + 2][2 * j + 1] = 1;
      }
    }
  }
  int res = flow();
  cout << res << '\n';
  return 0;
}