#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int to[N], ww[N], nxt[N], tt = 1, s, t, dep[N], h[N], cur[N], n, w, m;
void adde(int u, int v, int w) {
  to[++tt] = v;
  ww[tt] = w;
  nxt[tt] = h[u];
  h[u] = tt;
  to[++tt] = u;
  ww[tt] = 0;
  nxt[tt] = h[v];
  h[v] = tt;
}
bool bfs() {
  memset(dep, 0, 4 * (t + 1));
  queue<int> q;
  q.push(s);
  dep[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = h[u], v; v = to[i], i; i = nxt[i])
      if (!dep[v] && ww[i]) {
        dep[v] = dep[u] + 1;
        q.push(v);
        if (v == t) return 1;
      }
  }
  return 0;
}
int dfs(int u, int flow) {
  if (u == t) return flow;
  int ret = 0;
  for (int &i = cur[u], v; v = to[i], i; i = nxt[i])
    if (dep[v] == dep[u] + 1 && ww[i]) {
      int d = dfs(v, min(flow, ww[i]));
      ww[i] -= d;
      ww[i ^ 1] += d;
      ret += d;
      flow -= d;
      if (!flow) break;
    }
  return ret;
}
int dinic() {
  int ret = 0;
  while (bfs()) {
    memcpy(cur, h, 4 * (t + 1));
    ret += dfs(s, inf);
  }
  return ret;
}
struct point {
  int x, y;
  point(int x = 0, int y = 0) : x(x), y(y) {}
  point operator+(const point &A) const { return point(x + A.x, y + A.y); }
  point operator-(const point &A) const { return point(x - A.x, y - A.y); }
  long long operator*(const point &A) const {
    return 1ll * x * A.x + 1ll * y * A.y;
  }
  long long operator%(const point &A) const {
    return 1ll * x * A.y - 1ll * y * A.x;
  }
  long long sqr_len() { return 1ll * x * x + 1ll * y * y; }
  bool operator<(const point &A) const {
    return make_pair(x, y) < make_pair(A.x, A.y);
  }
};
long long sqr_dist(const point &A, const point &B) { return (A - B).sqr_len(); }
vector<point> merge(vector<point> P, vector<point> Q) {
  vector<point> ret;
  rotate(P.begin(), min_element(P.begin(), P.end()), P.end());
  rotate(Q.begin(), min_element(Q.begin(), Q.end()), Q.end());
  ret.push_back(P[0] + Q[0]);
  vector<point> vP(int(P.size())), vQ(int(Q.size()));
  for (int i = 0; i < int(P.size()); i++)
    vP[i] = P[(i + 1) % int(P.size())] - P[i];
  for (int i = 0; i < int(Q.size()); i++)
    vQ[i] = Q[(i + 1) % int(Q.size())] - Q[i];
  for (int i = 0, j = 0; i < int(P.size()) || j < int(Q.size());) {
    if (j == int(Q.size()) || (i < int(P.size()) && vP[i] % vQ[j] >= 0))
      ret.push_back(ret.back() + vP[i++]);
    else
      ret.push_back(ret.back() + vQ[j++]);
  }
  ret.pop_back();
  return ret;
}
bool check(point P, vector<point> C, int lim) {
  bool fl = 1;
  for (int i = 0; i < int(C.size()); i++) {
    point A = C[i], B = C[(i + 1) % int(C.size())];
    if (sqr_dist(P, A) < 1ll * lim * lim) {
      return 1;
    }
    if ((P - A) * (B - A) > 0 && (P - B) * (A - B) > 0) {
      long long x = abs((P - A) % (B - A));
      if (x * x < 1ll * lim * lim * sqr_dist(A, B)) {
        return 1;
      }
    }
    fl &= (P - A) % (B - A) <= 0;
  }
  return fl;
}
int main() {
  cin >> n >> w;
  int mn = 1e9, mx = -1e9;
  vector<point> P(n), Q(n);
  for (int i = 0, x, y; i < n; i++) {
    x = gi();
    y = gi();
    P[i] = point(x, y);
    Q[i] = point(-x, -y);
    mn = min(mn, x);
    mx = max(mx, x);
  }
  P = merge(P, Q);
  cin >> m;
  s = m + m;
  t = m + m + 1;
  vector<point> C(m);
  vector<int> r(m);
  for (int i = 0, x, y; i < m; i++) {
    x = gi();
    y = gi();
    C[i] = point(x, y);
    r[i] = gi();
  }
  for (int i = 0; i < m; i++) {
    adde(i, i + m, 1);
    if (mx - mn > C[i].x - r[i]) {
      adde(s, i, inf);
    }
    if (mx - mn > w - (C[i].x + r[i])) {
      adde(i + m, t, inf);
    }
  }
  for (int i = 0; i < m; i++)
    for (int j = i + 1; j < m; j++)
      if (check(C[i] - C[j], P, r[i] + r[j])) {
        adde(i + m, j, inf);
        adde(j + m, i, inf);
      }
  cout << dinic();
  return 0;
}
