#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;
}
