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