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;
struct point {
  int x, y;
  point(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  point operator+(const point& a) { return point(x + a.x, y + a.y); }
  void operator+=(const point& a) {
    x += a.x;
    y += a.y;
  }
  point operator-(const point& a) { return point(x - a.x, y - a.y); }
  point operator-() { return point(-x, -y); }
  void operator-=(const point& a) {
    x -= a.x;
    y -= a.y;
  }
  long long operator^(const point& a) const {
    return (long long)x * a.y - (long long)y * a.x;
  }
  long long operator*(const point& a) {
    return (long long)x * a.x + (long long)y * a.y;
  }
  long long nor() { return (long long)x * x + (long long)y * y; }
  int pos() const { return x < 0 || (!x && y < 0); }
  bool operator<(const point& a) const {
    if (pos() != a.pos()) return pos() < a.pos();
    return (*this ^ a) > 0;
  }
  void scan() { scanf("%d%d", &x, &y); }
  void print() { printf("%d %d\n", x, y); }
};
long double angle(point a, point b) {
  return atan2l((long double)(a ^ b), (long double)(a * b));
}
bool point_touch_circle(point a, int r) { return a.nor() < (long long)r * r; }
bool segment_touch_circle(point a, point b, int r) {
  if ((a - b) * (-b) < 0ll) return point_touch_circle(b, r);
  if ((b - a) * (-a) < 0ll) return point_touch_circle(a, r);
  long long area = abs(a ^ b);
  return (long long)area * area < (long long)(a - b).nor() * r * r;
}
bool polygon_touch_circle(point* a, int n, int r) {
  a[n] = a[0];
  for (int i = 0; i < n; i++) {
    if (segment_touch_circle(a[i], a[i + 1], r)) {
      return true;
    }
  }
  long double tot = 0;
  for (int i = 0; i < n; i++) {
    tot += angle(a[i], a[i + 1]);
  }
  return tot > 0.5;
}
const int NN = 444;
const int MM = NN * NN;
point a[NN], b[NN], c[NN], jel[NN];
int r[NN];
int V, E, src, tar;
int head[NN], work[NN], dis[NN];
int to[MM], cap[MM], nxt[MM];
int q[NN], qf, qb;
void init(int n, int s, int t) {
  V = n;
  E = 0;
  src = s;
  tar = t;
  memset(head, -1, sizeof(int) * V);
}
void add_edge(int u, int v, int c) {
  to[E] = v;
  cap[E] = c;
  nxt[E] = head[u];
  head[u] = E++;
  to[E] = u;
  cap[E] = 0;
  nxt[E] = head[v];
  head[v] = E++;
}
bool bfs() {
  memset(dis, -1, sizeof(int) * V);
  qf = qb = 0;
  q[qb++] = src;
  dis[src] = 0;
  while (qf < qb && dis[tar] == -1) {
    int u = q[qf++];
    for (int i = head[u]; i >= 0; i = nxt[i]) {
      int v = to[i];
      if (dis[v] == -1 && cap[i] > 0) {
        dis[v] = dis[u] + 1;
        q[qb++] = v;
      }
    }
  }
  return dis[tar] >= 0;
}
int dfs(int u, int& bot) {
  int v, bot1, delta;
  if (u == tar) return bot;
  for (int& i = work[u]; i >= 0; i = nxt[i]) {
    int v = to[i];
    if (dis[v] != dis[u] + 1 || cap[i] == 0) continue;
    bot1 = min(bot, cap[i]);
    if (delta = dfs(v, bot1)) {
      cap[i] -= delta;
      cap[i ^ 1] += delta;
      bot = bot1;
      return delta;
    }
  }
  return 0;
}
const int inf = 0x3f3f3f3f;
int dinic() {
  int ans = 0, delta, bot;
  while (bfs()) {
    memcpy(work, head, sizeof(int) * V);
    delta = inf;
    while (delta = dfs(src, bot = inf)) ans += delta;
  }
  return ans;
}
int main() {
  int n, m, width, i, j, k;
  int pst = inf, ped = -inf;
  scanf("%d%d", &n, &width);
  for (i = 0; i < n; i++) {
    a[i].scan();
    pst = min(pst, a[i].x);
    ped = max(ped, a[i].x);
  }
  pst = ped - pst;
  a[n] = a[0];
  for (i = j = 0; i < n; i++) {
    b[j++] = a[i + 1] - a[i];
    b[j++] = a[i] - a[i + 1];
  }
  sort(b, b + (n << 1));
  for (i = 1; i < (n << 1); i++) b[i] += b[i - 1];
  point md = point((b[0].x + b[n].x) / 2, (b[0].y + b[n].y) / 2);
  for (i = 0; i < (n << 1); i++) b[i] -= md;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    jel[i].scan();
    scanf("%d", r + i);
  }
  int src = m << 1;
  int tar = src + 1;
  init(tar + 10, src, tar);
  for (i = 0; i < m; i++) {
    add_edge(i << 1, (i << 1) + 1, 1);
    if (pst > jel[i].x - r[i]) {
      add_edge(src, i << 1, inf);
    }
    if (width - (jel[i].x + r[i]) < pst) {
      add_edge((i << 1) + 1, tar, inf);
    }
    for (j = i + 1; j < m; j++) {
      point q = jel[j] - jel[i];
      for (k = n << 1; k--;) {
        c[k] = b[k] - q;
      }
      if (polygon_touch_circle(c, n << 1, r[i] + r[j])) {
        add_edge((i << 1) + 1, j << 1, 1);
        add_edge((j << 1) + 1, i << 1, 1);
      }
    }
  }
  printf("%d\n", dinic());
  return 0;
}