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 std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::get;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::tuple;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
template <typename T>
struct vec {
  T x;
  T y;
};
template <typename T>
vec<T> operator+(vec<T> a, vec<T> b) {
  return vec<T>{a.x + b.x, a.y + b.y};
}
template <typename T>
vec<T> operator-(vec<T> a, vec<T> b) {
  return vec<T>{a.x - b.x, a.y - b.y};
}
template <typename U, typename T>
vec<U> cast(vec<T> v) {
  return vec<U>{(U)v.x, (U)v.y};
}
int64_t cross64(vec<int> a, vec<int> b) {
  return a.x * int64_t(b.y) - b.x * int64_t(a.y);
}
int64_t dot64(vec<int> a, vec<int> b) {
  return a.x * int64_t(b.x) + a.y * int64_t(b.y);
}
int64_t dist2(vec<int> a) { return a.x * int64_t(a.x) + a.y * int64_t(a.y); }
template <typename T>
vec<T> rot90(vec<T> a) {
  return vec<T>{-a.y, a.x};
}
vector<vec<int>> minkowsky_sum(vector<vec<int>> a, vector<vec<int>> b) {
  auto kek = [&](vector<vec<int>>& v) {
    auto it = std::min_element(v.begin(), v.end(), [](vec<int> u, vec<int> w) {
      return make_pair(u.x, u.y) < make_pair(w.x, w.y);
    });
    std::rotate(v.begin(), it, v.end());
  };
  kek(a);
  kek(b);
  int n = int((a).size());
  int m = int((b).size());
  a.push_back(a[0]);
  a.push_back(a[1]);
  b.push_back(b[0]);
  b.push_back(b[1]);
  vector<vec<int>> res;
  int p = 0, q = 0;
  while (p < n or q < m) {
    res.push_back(a[p] + b[q]);
    if (cross64(a[p + 1] - a[p], b[q + 1] - b[q]) > 0)
      ++p;
    else if (cross64(a[p + 1] - a[p], b[q + 1] - b[q]) < 0)
      ++q;
    else
      ++p, ++q;
  }
  return res;
}
bool inside(const vector<vec<int>>& poly, vec<int> pt) {
  for (int i = 0; i != int((poly).size()); ++i) {
    int j = (i + 1) % int((poly).size());
    if (cross64(poly[i] - pt, poly[j] - pt) == 0 and
        dot64(poly[i] - pt, poly[j] - pt) <= 0)
      return true;
  }
  double ang = 0;
  for (int i = 0; i != int((poly).size()); ++i) {
    int j = (i + 1) % int((poly).size());
    ang += atan2(cross64(poly[i] - pt, poly[j] - pt),
                 dot64(poly[i] - pt, poly[j] - pt));
  }
  return abs(ang - 2.0 * acos(-1)) < 1e-3;
}
bool ok(const vector<vec<int>>& poly, vec<int> pt, int rad) {
  for (auto elem : poly)
    if (dist2(pt - elem) < rad * int64_t(rad)) return false;
  if (inside(poly, pt)) return false;
  for (int i = 0; i != int((poly).size()); ++i) {
    auto p = poly[i];
    auto q = poly[(i + 1) % int((poly).size())];
    if (dot64(q - p, pt - p) <= 0) continue;
    if (dot64(p - q, pt - q) <= 0) continue;
    auto norm = rot90(q - p);
    int64_t c = norm.x * p.x + norm.y * p.y;
    int64_t dst = abs(norm.x * pt.x + norm.y * pt.y - c);
    if (dst * dst < rad * rad * dist2(norm)) return false;
  }
  return true;
}
struct edge_t {
  int to;
  int flow;
  int cap;
  int next;
};
int push(vector<int>& head, vector<edge_t>& edges, vector<char>& used, int v,
         int T, int mx) {
  if (v == T) return mx;
  used[v] = 1;
  for (int e = head[v]; e != -1; e = edges[e].next)
    if (edges[e].flow < edges[e].cap and not used[edges[e].to]) {
      int val = push(head, edges, used, edges[e].to, T,
                     min(mx, edges[e].cap - edges[e].flow));
      if (val > 0) {
        edges[e].flow += val;
        edges[e ^ 1].flow -= val;
        return val;
      }
    }
  return 0;
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int min_x = std::numeric_limits<int>::max(),
      max_x = std::numeric_limits<int>::min();
  int n = input<int>();
  int w = input<int>();
  vector<vec<int>> poly(n);
  for (int i = 0; i != n; ++i) {
    cin >> poly[i].x >> poly[i].y;
    min_x = min(min_x, poly[i].x);
    max_x = max(max_x, poly[i].x);
  }
  for (int i = 0; i != n; ++i) poly[i].x -= min_x;
  max_x -= min_x;
  int m = input<int>();
  vector<pair<vec<int>, int>> jelly(m);
  for (auto& elem : jelly) cin >> elem.first.x >> elem.first.y >> elem.second;
  vector<vec<int>> antipoly(n);
  for (int i = 0; i != n; ++i) antipoly[i] = {-poly[i].x, -poly[i].y};
  auto poly_minus_poly = minkowsky_sum(poly, antipoly);
  int S = 2 * m;
  int T = 2 * m + 1;
  vector<int> head(2 * m + 2, -1);
  vector<edge_t> edges;
  auto add_edge = [&](int v, int u, int cap, int rcap) {
    edges.push_back(edge_t{u, 0, cap, head[v]});
    head[v] = int((edges).size()) - 1;
    edges.push_back(edge_t{v, 0, rcap, head[u]});
    head[u] = int((edges).size()) - 1;
  };
  const int inf = 1e3;
  for (int i = 0; i < m; ++i) add_edge(2 * i + 1, 2 * i, 1, 0);
  for (int i = 0; i < m; ++i)
    for (int j = i + 1; j < m; ++j) {
      if (not ok(poly_minus_poly, jelly[i].first - jelly[j].first,
                 jelly[i].second + jelly[j].second)) {
        add_edge(2 * i, 2 * j + 1, inf, 0);
        add_edge(2 * j, 2 * i + 1, inf, 0);
      }
    }
  for (int i = 0; i != m; ++i) {
    int L = jelly[i].first.x - jelly[i].second - max_x;
    int R = jelly[i].first.x + jelly[i].second;
    if (L < 0) {
      add_edge(S, 2 * i + 1, inf, 0);
    }
    if (R > w - max_x) {
      add_edge(2 * i, T, inf, 0);
    }
  }
  int flow = 0;
  while (true) {
    vector<char> used(2 * m + 2, false);
    int tmp;
    if ((tmp = push(head, edges, used, S, T,
                    std::numeric_limits<int>::max())) != 0)
      flow += tmp;
    else
      break;
  }
  cout << flow << "\n";
  return 0;
}