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>
#include <bits/stdc++.h>
using namespace std;
int dis, t, hull[422], k, sz, ch, ch2, n, m, mini = -1, w, i, j, x[422], y[422],
                                             r[422];
long long R;
struct MaxFlowDinic {
  struct Edge {
    int next;
    size_t inv;
    int res;
  };
  int n;
  vector<vector<Edge> > graph;
  vector<int> q, l, start;
  void init(int _n) {
    n = _n;
    graph.resize(n);
    for (int i = 0; i < n; i++) graph[i].clear();
  }
  void add_edge(int s, int e, int cap, int caprev = 0) {
    Edge forward{e, graph[e].size(), cap};
    Edge reverse{s, graph[s].size(), caprev};
    graph[s].push_back(forward);
    graph[e].push_back(reverse);
  }
  bool assign_level(int source, int sink) {
    int t = 0;
    memset(&l[0], 0, sizeof(l[0]) * l.size());
    l[source] = 1;
    q[t++] = source;
    for (int h = 0; h < t && !l[sink]; h++) {
      int cur = q[h];
      for (const auto& e : graph[cur]) {
        if (l[e.next] || e.res == 0) continue;
        l[e.next] = l[cur] + 1;
        q[t++] = e.next;
      }
    }
    return l[sink] != 0;
  }
  int block_flow(int cur, int sink, int current) {
    if (cur == sink) return current;
    for (int& i = start[cur]; i < graph[cur].size(); i++) {
      auto& e = graph[cur][i];
      if (e.res == 0 || l[e.next] != l[cur] + 1) continue;
      if (int res = block_flow(e.next, sink, min(e.res, current))) {
        e.res -= res;
        graph[e.next][e.inv].res += res;
        return res;
      }
    }
    return 0;
  }
  int solve(int source, int sink) {
    q.resize(n);
    l.resize(n);
    start.resize(n);
    int ans = 0;
    while (assign_level(source, sink)) {
      memset(&start[0], 0, sizeof(start[0]) * n);
      while (int flow = block_flow(source, sink, numeric_limits<int>::max()))
        ans += flow;
    }
    return ans;
  }
};
long long sq(long long T) { return T * T; }
struct A {
  long long x, y;
} d[40004];
int ccw(A a, A b, A c) {
  long long ch =
      a.x * b.y + b.x * c.y + c.x * a.y - a.y * b.x - b.y * c.x - c.y * a.x;
  if (ch < 0) return -1;
  if (ch > 0) return 1;
  return 0;
}
bool cmp(A aa, A bb) {
  if (ccw(d[0], aa, bb))
    return ccw(d[0], aa, bb) > 0;
  else
    return aa.x - d[0].x < bb.x - d[0].x;
}
int main() {
  scanf("%d%d", &n, &w);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
  }
  dis = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      dis = max(dis, x[i] - x[j]);
    }
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &x[n + i], &y[n + i], &r[n + i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      d[sz++] = {x[i] - x[j], y[i] - y[j]};
      if (mini == -1 || (d[sz - 1].x < d[mini].x) ||
          (d[sz - 1].x == d[mini].x && d[sz - 1].y < d[mini].y))
        mini = sz - 1;
    }
  }
  swap(d[0], d[mini]);
  sort(d + 1, d + sz, cmp);
  hull[t++] = 0;
  hull[t++] = 1;
  for (i = 2; i < sz; i++) {
    while (t > 1 && ccw(d[hull[t - 2]], d[hull[t - 1]], d[i]) <= 0) t--;
    hull[t++] = i;
  }
  hull[t] = hull[0];
  MaxFlowDinic G;
  G.init(2 * m + 2);
  for (i = 0; i < m; i++) {
    if (x[n + i] - r[n + i] < dis) {
      G.add_edge(2 * m, 2 * i, 1e9);
    }
    if (x[n + i] + r[n + i] + dis > w) {
      G.add_edge(2 * i + 1, 2 * m + 1, 1e9);
    }
    G.add_edge(2 * i, 2 * i + 1, 1);
  }
  A p, q, o;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++) {
      o.x = x[n + j] - x[n + i];
      o.y = y[n + j] - y[n + i];
      R = r[n + j] + r[n + i];
      ch = 0;
      ch2 = 0;
      for (k = 0; k < t; k++) {
        p = d[hull[k]], q = d[hull[k + 1]];
        if (ccw(p, q, o) >= 0)
          ch++;
        else {
          if ((sq(p.x - q.x) + sq(p.y - q.y)) +
                  (sq(o.x - q.x) + sq(o.y - q.y)) <=
              (sq(p.x - o.x) + sq(p.y - o.y))) {
            if ((sq(o.x - q.x) + sq(o.y - q.y)) < sq(R)) ch2 = 1;
          } else if ((sq(p.x - q.x) + sq(p.y - q.y)) +
                         (sq(p.x - o.x) + sq(p.y - o.y)) <=
                     (sq(o.x - q.x) + sq(o.y - q.y))) {
            if ((sq(p.x - o.x) + sq(p.y - o.y)) < sq(R)) ch2 = 1;
          } else {
            if (sq(p.x * q.y + q.x * o.y + o.x * p.y - p.y * q.x - q.y * o.x -
                   o.y * p.x) < (sq(p.x - q.x) + sq(p.y - q.y)) * sq(R))
              ch2 = 1;
          }
        }
      }
      if (ch == t || ch2 == 1) {
        G.add_edge(2 * i + 1, 2 * j, 1e9);
        G.add_edge(2 * j + 1, 2 * i, 1e9);
      }
    }
  }
  printf("%d", G.solve(2 * m, 2 * m + 1));
}
