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;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
struct Point {
  long long x, y;
  Point() {}
  Point(long long x, long long y) : x(x), y(y) {}
  long long abs() const { return x * x + y * y; }
  long double arg() const { return atan2(y, x); }
  Point operator*(long long o) const { return Point(x * o, y * o); }
  Point operator+(const Point &o) const { return Point(x + o.x, y + o.y); }
  Point operator-(const Point &o) const { return Point(x - o.x, y - o.y); }
  Point operator/(double o) const { return Point(x / o, y / o); }
  bool operator<(const Point &o) const {
    return x < o.x || (x < o.x && y < o.y);
  }
  friend bool operator==(const Point &r1, const Point &r2) {
    return r1.x == r2.x && r1.y == r2.y;
  }
  Point scale(double o) const { return *this * (o / abs()); }
  Point rotY() const { return Point(-y, x); }
  Point rotX() const { return Point(y, -x); }
  long long cross(Point b) const { return x * b.y - b.x * y; }
  long long dot(Point b) const { return x * b.x + y * b.y; }
  long double disToSeg(Point &a, Point &b) {
    return fabs(((*this) - a).cross(b - a) / (b - a).abs());
  }
  pair<long long, long long> getVec() {
    if (x == 0) return {0, y > 0 ? 1 : -1};
    if (y == 0) return {x < 0 ? -1 : 1, 0};
    long long gg = gcd1(::abs(x), ::abs(y));
    long long px = x / gg, py = y / gg;
    return {px, py};
  }
  void readin() { scanf("%lld%lld", &x, &y); }
  long long r;
  void readcc() { scanf("%lld%lld%lld", &x, &y, &r); }
};
struct Line {
  Point s, t;
  Line() {}
  Line(Point p, Point q) {
    s = p;
    t = q;
  }
  bool isPointOnSeg(Point p) {
    return ((p - s).cross(t - s)) == 0 && ((p.x - s.x) * (p.x - t.x)) <= 0 &&
           ((p.y - s.y) * (p.y - t.y)) <= 0;
  }
};
namespace minkoSum {
vector<Point> init(vector<Point> p) {
  vector<Point> ans;
  int pos = min_element(p.begin(), p.end()) - p.begin();
  for (int(i) = 0; (i) < (int)(p.size()); (i)++)
    ans.push_back(p[(i + pos) % p.size()]);
  return ans;
}
vector<Point> merge(vector<Point> p, vector<Point> q) {
  p = init(p);
  q = init(q);
  int szp = p.size(), szq = q.size();
  vector<Point> d1(szp), d2(szq);
  for (int(i) = 0; (i) < (int)(szp); (i)++) d1[i] = p[(i + 1) % szp] - p[i];
  for (int(i) = 0; (i) < (int)(szq); (i)++) d2[i] = q[(i + 1) % szq] - q[i];
  vector<Point> ans;
  ans.push_back(p[0] + q[0]);
  int pos1 = 0, pos2 = 0;
  for (; pos1 < szp || pos2 < szq;)
    if (pos2 == szq)
      ans.push_back(ans.back() + d1[pos1++]);
    else if (pos1 == szp)
      ans.push_back(ans.back() + d2[pos2++]);
    else
      ans.push_back(ans.back() +
                    (d2[pos2].cross(d1[pos1]) >= 0 ? d2[pos2++] : d1[pos1++]));
  return ans;
}
bool vectorIn(Point p, long long r, vector<Point> &convexSumPts) {
  for (auto i : convexSumPts)
    if ((p - i).abs() < r * r) return 1;
  for (int(i) = 0; (i) < (int)(convexSumPts.size()); (i)++) {
    Point L = convexSumPts[i], R = convexSumPts[(i + 1) % convexSumPts.size()];
    if (((p - L).dot(R - L)) > 0 && ((p - R).dot(L - R)) > 0) {
      long long x = (p - L).cross(R - L);
      if (x * x < r * r * (L - R).abs()) return 1;
    }
  }
  for (int(i) = 0; (i) < (int)(convexSumPts.size()); (i)++) {
    Line zz =
        Line(convexSumPts[i], convexSumPts[(i + 1) % convexSumPts.size()]);
    if (zz.isPointOnSeg(p)) return 1;
  }
  bool flag = 1;
  for (int(i) = 0; (i) < (int)(convexSumPts.size()); (i)++)
    flag &= (((p - convexSumPts[i])
                  .cross(convexSumPts[(i + 1) % convexSumPts.size()] -
                         convexSumPts[i])) <= 0);
  return flag;
}
};  // namespace minkoSum
class MaxFlow {
 public:
  int cap[100000], flow[100000];
  int to[100000], prev[100000], last[1000], used[1000], level[1000];
  int V, E;
  MaxFlow(int n) {
    V = n;
    E = 0;
    for (int(i) = 0; (i) < (int)(V); (i)++) last[i] = -1;
  }
  void init(int n, int es) {
    V = n;
    E = 0;
    for (int(i) = 0; (i) < (int)(V); (i)++) last[i] = -1;
    for (int(i) = 0; (i) < (int)(V); (i)++) {
      used[i] = 0;
      level[i] = 0;
    }
    for (int(i) = 0; (i) < (int)(es); (i)++) {
      cap[i] = flow[i] = to[i] = prev[i] = 0;
    }
  }
  void add_edge(int x, int y, int f) {
    cap[E] = f;
    flow[E] = 0;
    to[E] = y;
    prev[E] = last[x];
    last[x] = E;
    E++;
    cap[E] = 0;
    flow[E] = 0;
    to[E] = x;
    prev[E] = last[y];
    last[y] = E;
    E++;
  }
  bool bfs(int s, int t) {
    int i;
    for (int(i) = 0; (i) < (int)(V); (i)++) level[i] = -1;
    queue<int> q;
    q.push(s);
    level[s] = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (i = last[x]; i >= 0; i = prev[i])
        if (level[to[i]] == -1 && cap[i] > flow[i]) {
          q.push(to[i]);
          level[to[i]] = level[x] + 1;
        }
    }
    return (level[t] != -1);
  }
  int dfs(int v, int t, int f) {
    int i;
    if (v == t) return f;
    for (i = used[v]; i >= 0; used[v] = i = prev[i])
      if (level[to[i]] > level[v] && cap[i] > flow[i]) {
        int tmp = dfs(to[i], t, min(f, cap[i] - flow[i]));
        if (tmp > 0) {
          flow[i] += tmp;
          flow[i ^ 1] -= tmp;
          return tmp;
        }
      }
    return 0;
  }
  vector<pair<int, int> > positive_edges() {
    vector<pair<int, int> > ans;
    for (int(i) = 0; (i) < (int)(V); (i)++)
      for (int j = last[i]; j >= 0; j = prev[j])
        if (cap[j] - flow[j] > 0) ans.push_back(make_pair(i, to[j]));
    return ans;
  }
  int maxflow(int s, int t) {
    while (bfs(s, t)) {
      for (int(i) = 0; (i) < (int)(V); (i)++) used[i] = last[i];
      while (dfs(s, t, (1 << 29)) != 0)
        ;
    }
    int ans = 0;
    for (int i = last[s]; i >= 0; i = prev[i]) ans += flow[i];
    return ans;
  }
};
Point fish[222];
void fmain(int tid) {
  int W;
  scanf("%d%d", &n, &W);
  vector<Point> p(n), q(n);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    p[i].readin();
    q[i] = p[i] * -1;
  }
  long long miX = p[0].x, maX = p[0].x;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    mintt(miX, p[i].x);
    maxtt(maX, p[i].x);
  }
  p = minkoSum::merge(p, q);
  scanf("%d", &m);
  int S = 0, T = m + m + 1;
  for (int(i) = 1; (i) <= (int)(m); (i)++) fish[i].readcc();
  MaxFlow mf = MaxFlow(T + 5);
  long long D = maX - miX;
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    mf.add_edge(i, m + i, 1);
    if (fish[i].x - fish[i].r < D) mf.add_edge(S, i, (1000000000));
    if (W - (fish[i].x + fish[i].r) < D) mf.add_edge(i + m, T, (1000000000));
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++)
    for (int j = i + 1; j <= m; j++) {
      if (minkoSum::vectorIn(fish[j] - fish[i], fish[i].r + fish[j].r, p)) {
        mf.add_edge(i + m, j, (1000000000));
        mf.add_edge(j + m, i, (1000000000));
      }
    }
  int tt = mf.maxflow(S, T);
  printf("%d\n", tt);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}