Problem: Klein is trying to get her dog Jack into the Frisbee Dog Tournament. But she's not sure if Jack will get a good grade. For her, she simulates the tournament to get Jack's grade. I want you to create a program to estimate.

The tournament is held by N dogs on a two-dimensional plane. At the start of the tournament, the i-th dog is in the (Dix, Diy) position. The i-th dog is Vi [m / s] All dogs are small enough to be considered points. At any given time, two or more dogs may be in the same position.

The tournament begins with the launch of the first Frisbee, from which the dogs are allowed to move. Frisbee can also be considered a point, the i Frisbee from the (FPix, FPiy) position ( FVix, FViy) Fired at a velocity vector of [m / s] and continues a constant velocity linear motion. When a dog's position and a Frisbee's position are equal, the dog can get a Frisbee.

The moment the first Frisbee is acquired by one of the dogs, the second Frisbee is fired. The moment the second Frisbee is acquired, the third is fired, and so on. Immediately after, the next Frisbee will be fired. The tournament will end when the Mth Frisbee is acquired.

Needless to say, the dogs' goal is to get more Frisbee. Dogs take the following strategies.

When the Frisbee is fired, the dog moves to get it at the earliest possible time and gets the Frisbee. However, if it cannot get the Frisbee, it waits where it is.

The determination of whether a dog can get a frisbee is made regardless of the behavior of the other dog. That is, one dog moves to get a frisbee, but the other dog gets it first. The moment one of the dogs gets the Frisbee and a new Frisbee is launched, the dogs take the above strategy against the new Frisbee.

The program you create must output the number of Frisbees obtained by each dog.



Input

The input file consists of multiple datasets.

The first row of the dataset gives the number of dogs N (1 ≤ N ≤ 10) and the number of Frisbees M (1 ≤ M ≤ 1000).

The following N lines are given the dog's initial position and velocity Dix, Diy, Vi, separated by a single blank.

The following M lines are given the Frisbee launch position and velocity FPix, FPiy, FVix, FViy, separated by a single space character.

The coordinate values ​​given are real numbers and their absolute values ​​do not exceed 1000. The speeds given are real numbers 1 ≤ DVi ≤ 100, -25 ≤ FVix, FViy ≤ 25. Frisbees that cannot be obtained by any dog You can assume that there is no.

When a dog with any Frisbee was obtained at time t, no dog could get it before time t + 1e-6.

During the simulation, the absolute values ​​of the dog's x and y coordinates do not exceed 1e + 8.

When both N and M are 0, the end of input is indicated.

Output

Output the number of Frisbees obtained by each dog on one line separated by a space character. The order of output must be the same as the order given in the input.

Example

Input

2 1
12 5 3
0 17 3
0 0 2 2
2 3
2 0 2
100 100 2
0 0 -1 0
-2 -5 0 3
100 100 1 1
0 0


Output

1 0
2 1

Solution (in CPP):

Solution:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
};
bool operator==(Point a,Point b){
	return abs(a.x-b.x)<EPS && abs(a.y-b.y)<EPS;
}
bool operator!=(Point a,Point b){
	return abs(a.x-b.x)>=EPS || abs(a.y-b.y)>=EPS;
}
Point operator+(Point a,Point b){
	return Point(a.x+b.x,a.y+b.y);
}
Point operator-(Point a,Point b){
	return Point(a.x-b.x,a.y-b.y);
}
Point operator*(double c,Point p){
	return Point(c*p.x,c*p.y);
}
Point operator/(Point p,double c){
	return Point(p.x/c,p.y/c);
}
double Abs2(Point p){
	return p.x*p.x+p.y*p.y;
}
double Dot(Point a,Point b){
	return a.x*b.x+a.y*b.y;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vector<Point> ds(n); vd ss(n); // 犬の位置と速度
		rep(i,n) cin>>ds[i].x>>ds[i].y>>ss[i];
		vector<Point> fs(m),us(m);     // フリスビーの発射位置と速度
		rep(i,m) cin>>fs[i].x>>fs[i].y>>us[i].x>>us[i].y;
		
		vi res(n);
		rep(i,m){
			vd ts(n,INFTY);
			vector<Point> vs(n,Point(0,0));
			rep(j,n){
				double a=Abs2(us[i])-ss[j]*ss[j];
				double b=2*Dot(fs[i]-ds[j],us[i]);
				double c=Abs2(fs[i]-ds[j]);
				if(b*b-4*a*c>EPS){
					double t1=(-b-sqrt(b*b-4*a*c))/(2*a);
					double t2=(-b+sqrt(b*b-4*a*c))/(2*a);
					if(t1>t2)
						swap(t1,t2);
					if(t1>EPS){
						ts[j]=t1;
						vs[j]=(fs[i]-ds[j])/t1+us[i];
					}
					else if(t2>EPS){
						ts[j]=t2;
						vs[j]=(fs[i]-ds[j])/t2+us[i];
					}
				}
			}
			int mi=min_element(all(ts))-ts.begin();
			res[mi]++;
			rep(j,n)
				ds[j]=ds[j]+ts[mi]*vs[j];
		}
		rep(i,n)
			cout<<res[i]<<(i<n-1?' ':'\n');
	}
	
	return 0;
}