//BZOJ 1027 合金
#include<iostream>
#include<cstring>
#include<cstdio>
#define eps 1e-6
#define inf 1e9+7
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=505;
int n,m,ans=inf;
int f[mxn][mxn];
double x[mxn],y[mxn],a[mxn],b[mxn],l,r;
inline int floyd()
{
int i,j,k;
fo(k,1,m)
fo(i,1,m)
if(f[i][k]<inf)
fo(j,1,m)
f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
fo(i,1,m) ans=min(ans,f[i][i]);
if(ans==inf) return -1;
return ans;
}
int main()
{
int i,j,k;
scanf("%d%d",&m,&n);
fo(i,1,m) scanf("%lf%lf%lf",&x[i],&y[i],&l);
fo(i,1,n) scanf("%lf%lf%lf",&a[i],&b[i],&r);
fo(i,1,m) fo(j,1,m) f[i][j]=inf;
fo(i,1,m)
fo(j,1,m)
{
bool flag=1;
fo(k,1,n)
{
double x1=a[k]-x[i],y1=b[k]-y[i];
double x2=a[k]-x[j],y2=b[k]-y[j];
double tmp=x1*y2-x2*y1; //叉积
if(tmp>=eps) {flag=0;break;}
if(tmp>-eps && tmp<eps && x1*x2+y1*y2>=eps) {flag=0;break;}
}
if(flag) f[i][j]=1;
}
printf("%d\n",floyd());
return 0;
}