import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
final int N = 50010, M = 500007;
long[] h = new long[M];
int[] id = new int[M];
boolean[] st = new boolean[M];
Circle[] cir = new Circle[N];
final long NULL = Long.MIN_VALUE;
int sqr(int x) {
return x * x;
}
long get_key(int x, int y) {
return (long)x * 1000000000 + y;
}
// 如果(x, y)存在, 返回它在数组中的下标, 否则返回应该插入的位置
int find(int x, int y) {
long key = get_key(x, y);
int t = (int) ((key % M + M) % M);
while(h[t] != NULL && h[t] != key) {
t++;
if(t == M) t = 0;
}
return t;
}
void dfs(int x, int y, int r) {
st[find(x, y)] = true;
for (int i = x - r; i <= x + r; i++) {
for (int j = y - r; j <= y + r; j++) {
if(sqr(i - x) + sqr(j - y) <= sqr(r)) {
int t = find(i, j);
if(id[t] != 0 && !st[t])
dfs(i, j, cir[id[t]].r);
}
}
}
}
public Main() throws IOException {
// 初始化哈希表
Arrays.fill(h, NULL);
String[] line = in.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int m = Integer.parseInt(line[1]);
for (int i = 1; i <= n; i++) {
line = in.readLine().split(" ");
int x = Integer.parseInt(line[0]);
int y = Integer.parseInt(line[1]);
int r = Integer.parseInt(line[2]);
cir[i] = new Circle(x, y, r);
int t = find(x, y);
if(h[t] == NULL) h[t] = get_key(x, y);
if(id[t] == 0 || r > cir[id[t]].r) {
id[t] = i;
}
}
while(m-- > 0) {
line = in.readLine().split(" ");
int x = Integer.parseInt(line[0]);
int y = Integer.parseInt(line[1]);
int r = Integer.parseInt(line[2]);
for (int i = x - r; i <= x + r; i++) {
for (int j = y - r; j <= y + r; j++) {
if(sqr(i - x) + sqr(j - y) <= sqr(r)) {
int t = find(i, j);
if(id[t] != 0 && !st[t])
dfs(i, j, cir[id[t]].r);
}
}
}
}
int res = 0;
for (int i = 1; i <= n; i++) {
int t = find(cir[i].x, cir[i].y);
if(st[t]) res++;
}
System.out.println(res);
in.close();
}
public static void main(String[] args) throws Exception {
new Main();
}
}
class Circle{
int x, y, r;
public Circle(int x, int y, int r) {
super();
this.x = x;
this.y = y;
this.r = r;
}
}