#include #define endl "\n" using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("war.in","r",stdin); freopen("war.out","w",stdout); } long long int n,m; struct voin { long long int x,y,p; void read() { cin>>x>>y>>p; } }; voin a[100001],b[100001]; bool cmp(voin a1,voin a2) { if(a1.p>a2.p)return false; return true; } void read() { cin>>n>>m; for(int i=1;i<=n;i++) { a[i].read(); } for(int i=1;i<=m;i++) { b[i].read(); } sort(b+1,b+1+m,cmp); } long long int br; struct com { long long int x1,x2,y1,y2,p; }; vectorv; long long int make_cv(long long int a1,long long int a2) { return ceil(sqrt(a1*a1-a2*a2)); } void resh() { for(int i=2;i<=n;i++) { com h; h.x1=a[i].x; h.y1=a[i].y; h.x2=a[1].x; h.y2=a[1].y; h.p=a[i].p; v.push_back(h); a[1].p+=h.p; } b[0].x=a[1].x; b[0].y=a[1].y; b[0].p=a[1].p; for(int i=1;i<=m;i++) { com h; h.x1=b[i-1].x; h.y1=b[i-1].y; h.x2=b[i].x; h.y2=b[i].y; h.p=b[i-1].p; v.push_back(h); b[i].p=make_cv(h.p,b[i].p); } cout<