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;
using namespace rel_ops;
using ll = int64_t;
using Pii = pair<int, int>;
using ull = uint64_t;
using Vi = vector<int>;
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  run();
  return 0;
}
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
int cmp(double a, double b, double eps = 1e-9) {
  return (a > b + eps) - (a + eps < b);
}
constexpr int INF = 1e9 + 10;
struct MaxFlow {
  using T = int;
  struct Edge {
    int dst, inv;
    T flow, cap;
  };
  struct Vert {
    vector<Edge> E;
    int prev;
    T add;
  };
  vector<Vert> G;
  MaxFlow(int n = 0) { init(n); }
  void init(int n) { G.assign(n, {}); }
  int addVert() {
    G.emplace_back();
    return int((G).size()) - 1;
  }
  void addEdge(int u, int v, int cap, int rcap = 0) {
    G[u].E.push_back({v, int((G[v].E).size()), 0, cap});
    G[v].E.push_back({u, int((G[u].E).size()) - 1, 0, rcap});
  }
  T maxFlow(int src, int dst) {
    T f = 0;
    do {
      for (auto& v : (G)) v.prev = v.add = -1;
      queue<int> Q;
      Q.push(src);
      G[src].add = INF;
      while (!Q.empty()) {
        int i = Q.front();
        T m = G[i].add;
        Q.pop();
        if (i == dst) {
          while (i != src) {
            auto& e = G[i].E[G[i].prev];
            e.flow -= m;
            G[e.dst].E[e.inv].flow += m;
            i = e.dst;
          }
          f += m;
          break;
        }
        for (auto& e : (G[i].E))
          if (G[e.dst].add < 0) {
            if (e.flow < e.cap) {
              Q.push(e.dst);
              G[e.dst].prev = e.inv;
              G[e.dst].add = min(m, e.cap - e.flow);
            }
          }
      }
    } while (G[dst].prev != -1);
    return f;
  }
};
template <class T, class S>
struct bvec2 {
  T first, second;
  S operator+(S r) const { return {first + r.first, second + r.second}; }
  S operator-(S r) const { return {first - r.first, second - r.second}; }
  S operator*(T r) const { return {first * r, second * r}; }
  S operator/(T r) const { return {first / r, second / r}; }
  T dot(S r) const { return first * r.first + second * r.second; }
  T cross(S r) const { return first * r.second - second * r.first; }
  T len2() const { return first * first + second * second; }
  S perp() const { return {-second, first}; }
  pair<T, T> yxPair() const { return make_pair(second, first); }
};
struct vec2i : bvec2<ll, vec2i> {
  vec2i() : bvec2{0, 0} {}
  vec2i(ll a, ll b) : bvec2{a, b} {}
  bool operator==(vec2i r) const {
    return first == r.first && second == r.second;
  }
  bool operator<(vec2i r) const {
    if (upper() != r.upper()) return upper();
    auto t = cross(r);
    return t > 0 || (!t && len2() < r.len2());
  }
  bool upper() const { return second > 0 || (second == 0 && first >= 0); }
};
using vec2 = vec2i;
template <class P, class S>
struct bseg2 {
  P a, b;
};
struct seg2i : bseg2<vec2i, seg2i> {
  seg2i() {}
  seg2i(vec2i c, vec2i d) : bseg2{c, d} {}
  bool contains(vec2i p) {
    return (a - p).dot(b - p) <= 0 && (a - p).cross(b - p) == 0;
  }
  int cmpDistTo(vec2i p, ll d2) const {
    if ((p - a).dot(b - a) < 0) {
      ll l = (p - a).len2();
      return (l > d2) - (l < d2);
    }
    if ((p - b).dot(a - b) < 0) {
      ll l = (p - b).len2();
      return (l > d2) - (l < d2);
    }
    ll c = abs((p - a).cross(b - a));
    d2 *= (b - a).len2();
    return (c * c > d2) - (c * c < d2);
  }
};
using seg2 = seg2i;
vec2 edgeSeq(vector<vec2> points, vector<vec2>& edges) {
  int i = 0, n = int((points).size());
  for (int j = (0); j < (n); j++) {
    if (points[i].yxPair() > points[j].yxPair()) i = j;
  }
  for (int j = (0); j < (n); j++)
    edges.push_back(points[(i + j + 1) % n] - points[(i + j) % n]);
  return points[i];
}
vector<vec2> hullSum(vector<vec2> A, vector<vec2> B) {
  vector<vec2> sum, e1, e2, es(int((A).size()) + int((B).size()));
  vec2 pivot = edgeSeq(A, e1) + edgeSeq(B, e2);
  merge((e1).begin(), (e1).end(), (e2).begin(), (e2).end(), es.begin());
  sum.push_back(pivot);
  for (auto& e : (es)) sum.push_back(sum.back() + e);
  sum.pop_back();
  return sum;
}
int insideHull(vector<vec2>& hull, vec2 p) {
  int ret = 1;
  for (int i = (0); i < (int((hull).size())); i++) {
    auto v = hull[(i + 1) % int((hull).size())] - hull[i];
    auto t = v.cross(p - hull[i]);
    ret = min(ret, (t > 0) - (t < 0));
  }
  return int(max(ret + 1, 0));
}
int cmpHullDist(vector<vec2>& hull, vec2 p, ll d2) {
  if (insideHull(hull, p)) return (d2 < 0) - (d2 > 0);
  int ret = 1;
  for (int i = (0); i < (int((hull).size())); i++) {
    seg2 seg{hull[(i + 1) % int((hull).size())], hull[i]};
    ret = min(ret, seg.cmpDistTo(p, d2));
  }
  return ret;
}
struct Circle {
  vec2 center;
  ll radius;
};
void run() {
  int n, w;
  cin >> n >> w;
  vector<vec2> bob(n), bobInv;
  ll minX = 1e18, maxX = -1e18;
  for (auto& v : (bob)) {
    cin >> v.first >> v.second;
    bobInv.push_back({-v.first, -v.second});
    minX = min(minX, v.first);
    maxX = max(maxX, v.first);
  }
  bob = hullSum(bob, bobInv);
  ll width = maxX - minX;
  minX = -minX;
  maxX = w * 2 - maxX;
  int m;
  cin >> m;
  vector<Circle> fishes(m);
  for (auto& f : (fishes)) cin >> f.center.first >> f.center.second >> f.radius;
  MaxFlow flow(m * 2 + 2);
  for (int i = (0); i < (m); i++) {
    ll x1 = fishes[i].center.first - fishes[i].radius;
    ll x2 = fishes[i].center.first + fishes[i].radius;
    flow.addEdge(i * 2 + 2, i * 2 + 3, 1);
    if (x1 < width) {
      flow.addEdge(0, i * 2 + 2, INF);
    }
    if (x2 > w - width) {
      flow.addEdge(i * 2 + 3, 1, INF);
    }
    for (int j = (i + 1); j < (m); j++) {
      auto p = fishes[i].center - fishes[j].center;
      auto r = fishes[i].radius + fishes[j].radius;
      if (cmpHullDist(bob, p, r * r) < 0) {
        flow.addEdge(i * 2 + 3, j * 2 + 2, INF);
        flow.addEdge(j * 2 + 3, i * 2 + 2, INF);
      }
    }
  }
  cout << flow.maxFlow(0, 1) << endl;
}