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;
const bool debug = 0;
struct pt {
  long long x, y;
  pt() {}
  pt(long long a, long long b) : x(a), y(b) {}
};
pt operator+(pt a, pt b) { return pt(a.x + b.x, a.y + b.y); }
pt operator-(pt a, pt b) { return pt(a.x - b.x, a.y - b.y); }
pt operator*(pt a, long long b) { return pt(a.x * b, a.y * b); }
pt operator/(pt a, long long b) { return pt(a.x / b, a.y / b); }
bool operator<(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }
bool operator>(pt a, pt b) { return b < a; }
long long cross(pt a, pt b) { return a.x * b.y - b.x * a.y; }
long long dot(pt a, pt b) { return a.x * b.x + a.y * b.y; }
long long sq(pt a) { return dot(a, a); }
long long dist(pt a, pt b) { return sq(a - b); }
struct line {
  pt v;
  long long c;
  line() {}
  line(pt a, pt b) : v(a - b), c(cross(v, a)) {}
};
long long side(line a, pt b) { return a.c - cross(a.v, b); }
void ccw(vector<pt> &a) {
  if (cross(a[1] - a[0], a[2] - a[0]) < 0) reverse(a.begin(), a.end());
}
void rot(vector<pt> &a) {
  ccw(a);
  int mn = 0;
  for (int i = 0; i < a.size(); i++)
    if (a[mn] > a[i]) mn = i;
  vector<pt> b;
  for (int i = 0; i < a.size(); i++) b.push_back(a[(mn + i) % a.size()]);
  a = b;
}
vector<pt> Minkowski(vector<pt> a, vector<pt> b) {
  rot(a);
  rot(b);
  int asz = a.size(), bsz = b.size();
  vector<pt> ret, d1, d2;
  for (int i = 0; i < asz; i++) d1.push_back(a[(i + 1) % asz] - a[i]);
  for (int i = 0; i < bsz; i++) d2.push_back(b[(i + 1) % bsz] - b[i]);
  ret.push_back(a[0] + b[0]);
  int i = 0, j = 0;
  while (i < asz || j < bsz) {
    if (i == asz)
      ret.push_back(ret.back() + d2[j++]);
    else if (j == bsz)
      ret.push_back(ret.back() + d1[i++]);
    else if (cross(d1[i], d2[j]) > 0)
      ret.push_back(ret.back() + d1[i++]);
    else
      ret.push_back(ret.back() + d2[j++]);
  }
  return ret;
}
vector<pt> operator-(vector<pt> a) {
  vector<pt> b;
  for (int i = 0; i < a.size(); i++) b.push_back(pt(-a[i].x, -a[i].y));
  return b;
}
bool CheckInside(vector<pt> a, pt b) {
  for (int i = 0; i < a.size(); i++)
    if (cross(a[i] - b, a[(i + 1) % a.size()] - b) < 0) return 0;
  return 1;
}
bool Check(vector<pt> a, pt b, long long r) {
  if (CheckInside(a, b)) return 1;
  for (pt p : a)
    if (dist(p, b) < r * r) return 1;
  for (int i = 0; i < a.size(); i++) {
    pt f = a[i], s = a[(i + 1) % a.size()];
    line l = line(s, f);
    if (!(dot(f, l.v) <= dot(b, l.v) && dot(b, l.v) <= dot(s, l.v))) continue;
    long long dist = abs(side(l, b));
    if (debug) {
      if (dist * dist < r * r * sq(l.v)) {
        printf("f:(%lld %lld) s:(%lld %lld) b:(%lld %lld)\n", f.x, f.y, s.x,
               s.y, b.x, b.y);
        printf("%lld %lld %lld\n", dot(f, l.v), dot(b, l.v), dot(s, l.v));
        printf("dist:%lld r*r*sq(l.v):%lld sq(l.v):%lld\n", dist,
               r * r * sq(l.v), sq(l.v));
      }
    }
    if (dist * dist < r * r * sq(l.v)) return 1;
  }
  return 0;
}
const int N = 100050;
const int inf = 1e9 + 7;
int s, t;
struct Edge {
  int u, v, c;
  Edge() {}
  Edge(int a, int b, int d) : u(a), v(b), c(d) {}
};
vector<Edge> edges;
vector<int> G[N];
void AddEdge(int u, int v, int c) {
  G[u].push_back(edges.size());
  edges.push_back(Edge(u, v, c));
  G[v].push_back(edges.size());
  edges.push_back(Edge(v, u, 0));
}
int was[N], Dist[N];
bool BFS() {
  for (int i = s; i <= t; i++) was[i] = 0, Dist[i] = inf;
  Dist[s] = 0;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int e : G[u]) {
      int v = edges[e].v;
      int c = edges[e].c;
      if (c && Dist[v] > Dist[u] + 1) {
        Dist[v] = Dist[u] + 1;
        q.push(v);
      }
    }
  }
  return Dist[t] != inf;
}
int Cut(int u, int flow) {
  if (u == t) return flow;
  if (Dist[u] >= Dist[t]) return 0;
  int ans = 0;
  for (; was[u] < G[u].size(); was[u]++) {
    int e = G[u][was[u]];
    int v = edges[e].v;
    int c = edges[e].c;
    if (!c || Dist[v] != Dist[u] + 1) continue;
    int cut = Cut(v, min(flow, c));
    edges[e].c -= cut;
    edges[e ^ 1].c += cut;
    ans += cut;
    flow -= cut;
    if (!flow) return ans;
  }
  return ans;
}
int MaxFlow() {
  int Flow = 0;
  while (BFS()) Flow += Cut(s, inf);
  return Flow;
}
struct circle {
  pt cen;
  long long r;
  circle() {}
  circle(long long x, long long y, long long z) : cen(x, y), r(z) {}
};
circle Jellyfish[N];
int main() {
  int n, W, m;
  scanf("%i %i", &n, &W);
  vector<pt> a, b, sum;
  a.resize(n);
  for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i].x, &a[i].y);
  long long mnx = inf, mxx = -inf;
  for (pt p : a) mnx = min(mnx, p.x), mxx = max(mxx, p.x);
  int len = mxx - mnx;
  b = -a;
  sum = Minkowski(a, b);
  scanf("%i", &m);
  s = 0;
  t = m * 2 + 1;
  for (int i = 1; i <= m; i++) {
    scanf("%lld %lld %lld", &Jellyfish[i].cen.x, &Jellyfish[i].cen.y,
          &Jellyfish[i].r);
    AddEdge(i * 2 - 1, i * 2, 1);
    if (Jellyfish[i].cen.x - Jellyfish[i].r < len) AddEdge(s, i * 2 - 1, inf);
    if (W - (Jellyfish[i].cen.x + Jellyfish[i].r) < len) AddEdge(i * 2, t, inf);
  }
  for (int i = 1; i <= m; i++)
    for (int j = i + 1; j <= m; j++) {
      if (Check(sum, Jellyfish[i].cen - Jellyfish[j].cen,
                Jellyfish[i].r + Jellyfish[j].r)) {
        AddEdge(i * 2, j * 2 - 1, inf);
        AddEdge(j * 2, i * 2 - 1, inf);
        if (debug) printf("(%i %i)\n", i, j);
      }
    }
  printf("%i\n", MaxFlow());
  if (debug)
    for (pt p : sum) printf("(%lld %lld) ", p.x, p.y);
  printf("\n");
  return 0;
}