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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
using namespace std;
template <typename T>
void uin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void uax(T &a, T b) {
  if (b > a) a = b;
}
const long long INF = 1e9 + 228;
namespace Dinic {
const long long N = 1000;
struct edge {
  long long from, to, cap, flow;
  edge() {}
  edge(long long _from, long long _to, long long _cap, long long _flow) {
    from = _from;
    to = _to;
    cap = _cap;
    flow = _flow;
  }
};
long long n;
vector<long long> g[N];
vector<edge> e;
long long fir[N], d[N], ptr = 0;
void add_edge(long long u, long long v, long long c) {
  e.push_back(edge(u, v, c, 0));
  g[u].push_back(ptr++);
  e.push_back(edge(v, u, 0, 0));
  g[v].push_back(ptr++);
}
bool bfs(long long s, long long t) {
  for (long long i = 1; i <= n; ++i) {
    d[i] = INF;
  }
  d[s] = 0;
  vector<long long> q;
  q.push_back(s);
  for (long long i = 0; i < (long long)q.size(); ++i) {
    long long v = q[i];
    for (long long num : g[v]) {
      long long to = e[num].to, cap = e[num].cap, flow = e[num].flow;
      if (d[v] + 1 < d[to] && cap - flow >= 1) {
        d[to] = d[v] + 1;
        q.push_back(to);
      }
    }
  }
  return d[t] != INF;
}
long long F = 0;
long long dfs(long long v, long long t, long long c = INF) {
  if (v == t) {
    F += c;
    return c;
  }
  for (; fir[v] < (long long)g[v].size(); ++fir[v]) {
    long long num = g[v][fir[v]];
    long long to = e[num].to, cap = e[num].cap, flow = e[num].flow;
    if (d[v] + 1 == d[to] && cap - flow >= 1) {
      long long x = dfs(to, t, min(c, cap - flow));
      if (x) {
        e[num].flow += x;
        e[num ^ 1].flow -= x;
        return x;
      }
    }
  }
  return 0;
}
long long flow(long long s, long long t) {
  F = 0;
  while (bfs(s, t)) {
    for (long long i = 1; i <= n; ++i) {
      fir[i] = 0;
    }
    while (dfs(s, t))
      ;
  }
  return F;
}
};  // namespace Dinic
struct pt {
  long long x, y;
  pt() {}
  pt(long long _x, long long _y) {
    x = _x;
    y = _y;
  }
};
pt operator+(const pt &a, const pt &b) { return pt(a.x + b.x, a.y + b.y); }
pt operator-(const pt &a, const pt &b) { return pt(a.x - b.x, a.y - b.y); }
long long operator*(const pt &a, const pt &b) { return a.x * b.y - a.y * b.x; }
long long operator%(const pt &a, const pt &b) { return a.x * b.x + a.y * b.y; }
long long get_dist(pt a, pt b) { return (b - a) % (b - a); }
pt o;
bool cmp(pt a, pt b) {
  return (a - o) * (b - o) < 0 ||
         ((a - o) * (b - o) == 0 && (a - o) % (a - o) < (b - o) % (b - o));
}
vector<pt> convex_hull(vector<pt> v) {
  o = v[0];
  for (pt p : v) {
    if (p.x < o.x || (p.x == o.x && p.y < o.y)) o = p;
  }
  sort(v.begin(), v.end(), cmp);
  v.push_back(v[0]);
  vector<pt> st;
  long long sz = 0;
  for (long long i = 0; i < (long long)v.size(); ++i) {
    while (sz > 1 && (v[i] - st[sz - 1]) * (st[sz - 1] - st[sz - 2]) <= 0) {
      st.pop_back();
      --sz;
    }
    ++sz;
    st.push_back(v[i]);
  }
  st.pop_back();
  return st;
}
bool belongs(pt a, pt b, pt p) {
  return (a - p) * (b - p) == 0 && (a - p) % (b - p) <= 0;
}
const long long N = 228;
long long n, m, w;
pt p[N], c[N];
long long r[N];
long long sign(long long x) {
  if (x > 0) return 1;
  return 0;
}
vector<pt> pol;
long long go(long long A, long long B) {
  pt P = c[B] - c[A];
  long long R = (r[A] + r[B]) * (r[A] + r[B]);
  bool kek[2];
  kek[0] = kek[1] = 0;
  for (long long i = 0; i < (long long)pol.size() - 1; ++i) {
    if (belongs(pol[i], pol[i + 1], P)) return 0;
    long long x = sign((pol[i] - P) * (pol[i + 1] - P));
    kek[x] = 1;
  }
  if (kek[0] && kek[1]) {
    for (long long i = 0; i < (long long)pol.size() - 1; ++i) {
      if ((P - pol[i]) % (pol[i + 1] - pol[i]) < 0) {
        if (get_dist(P, pol[i]) < R) return 0;
      } else if ((P - pol[i + 1]) % (pol[i] - pol[i + 1]) < 0) {
        if (get_dist(P, pol[i + 1]) < R) return 0;
      } else {
        long long up = abs((pol[i] - P) * (pol[i + 1] - P));
        up *= up;
        long long down = get_dist(pol[i], pol[i + 1]);
        if (up < R * down) return 0;
      }
    }
    return 1;
  } else
    return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w;
  for (long long i = 1; i <= n; ++i) {
    cin >> p[i].x >> p[i].y;
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      pol.push_back(p[i] - p[j]);
    }
  }
  pol = convex_hull(pol);
  pol.push_back(pol[0]);
  cin >> m;
  for (long long i = 1; i <= m; ++i) {
    cin >> c[i].x >> c[i].y >> r[i];
  }
  Dinic::n = 2 * m + 2;
  for (long long i = 1; i <= m; ++i) {
    Dinic::add_edge(2 * i, 2 * i + 1, 1);
  }
  for (long long i = 1; i <= m; ++i) {
    for (long long j = i + 1; j <= m; ++j) {
      if (!go(i, j)) {
        Dinic::add_edge(2 * i + 1, 2 * j, INF);
        Dinic::add_edge(2 * j + 1, 2 * i, INF);
      }
    }
  }
  long long s = 1, t = 2 * m + 2;
  s = 10011;
  s -= 10010;
  for (long long i = 1; i <= m; ++i) {
    pt left228 = p[1], right228 = p[1];
    for (long long j = 1; j <= n; ++j) {
      if (p[j].x < left228.x) left228 = p[j];
      if (p[j].x > right228.x) right228 = p[j];
    }
    if (right228.x - left228.x > c[i].x - r[i]) {
      Dinic::add_edge(s, 2 * i, INF);
    }
    if (right228.x - left228.x > w - c[i].x - r[i]) {
      Dinic::add_edge(2 * i + 1, t, INF);
    }
  }
  cout << Dinic::flow(s, t) << '\n';
  return 0;
}