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<complex>
#include<vector>
#include<iostream>
#include<stack>
#include<cmath>

#define sc second
#define fr first

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

typedef double elem;
typedef complex<elem> point, vec;
typedef pair<point, point> line, hline, seg, pp;

const double eps = 1.0e-6;
const double pi = acos(-1.0);
const double infty = 1e120;
point base(0,0);

// lZ
inline elem sq(elem a){ return a*a; }
inline elem cq(elem a){ return a*a*a; }

// pxÏ·
elem rad(elem deg){ return (deg/180)*pi; }
elem deg(elem rad){ return (rad*180)/pi; }

// ®¬_Ìô¢AÈÇ
bool eq(elem a, elem b){ return abs(a-b) < eps; }
bool lt(elem a, elem b){ return !eq(a,b) && a < b; }
bool leq(elem a, elem b){ return eq(a,b) || a < b; }
bool gt(elem a, elem b){ return !eq(a,b) && a > b; }
bool geq(elem a, elem b){ return eq(a,b) || a > b; }
bool ltz(elem a){ return lt( a, 0 ); }
bool gtz(elem a){ return gt( a, 0 ); }
bool eqv(vec a, vec b){ return eq( abs(b-a),0); }
bool is_zv(vec v){ return eq(abs(v),0); }
elem emax(elem a, elem b){ return gt(a,b)?a:b; }
elem emin(elem a, elem b){ return lt(a,b)?a:b; }

// _Iy[^
bool far(point a, point b){ return gtz( abs(b-a) ); }
bool near(point a, point b){ return leq( abs(b-a), 0 ); }
elem dot(vec a, vec b){ return (a.real() * b.real() + a.imag() * b.imag() ); }
elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); }

// a©çbÜÅvñèÌpxAàpA]ñ]
elem varg(vec a, vec b){
  elem ret=arg(a)-arg(b);
  if(lt(ret,0))ret+=2*pi;
  if(gt(ret,2*pi))ret-=2*pi;
  if(eq(ret,2*pi))ret=0;
  return ret;
}
elem arg(vec a, vec b){ return acos( dot(a,b) / ( abs(a) * abs(b) ) ); }
point rot(point p, elem theta){ return p * polar((elem)1.0, theta); }
point rotdeg(point p, elem deg){ return p * polar((elem)1.0, rad(deg)); }
point proj(line l, point p){
  double t=dot(p-l.first,l.first-l.second)/abs(l.first-l.second);
  return l.first + t*(l.first-l.second);
}
point reflect(line l, point p){ return p+2.0*(proj(l,p)-p); }

// ñ_Ô£A¼üÆ_ÌÅZ£AüªÆ_ÌÅZ£
elem dist(point a, point b){ return abs(a-b); }
elem dist_l(line l, point x){ return abs(cross(l.sc-l.fr,x-l.fr)) / abs(l.sc-l.fr); }
elem dist_seg(seg s, point x)
{
  if( ltz( dot(s.sc-s.fr,x-s.fr) ) ) return abs(x-s.fr);
  if( ltz( dot(s.fr-s.sc,x-s.sc) ) ) return abs(x-s.sc);
  return dist_l(s,x);
}

// PÊxNgA@üxNgAPÊ@üxNg
vec uvec(vec a){ return a / abs(a); }
vec nmr(vec a){ return a * vec(0,-1); }
vec nml(vec a){ return a * vec(0,1); }
vec unmr(vec a){ return uvec( nmr(a) ); }
vec unml(vec a){ return uvec( nml(a) ); }


class Dog{
public:
  point p;
  elem v;
  int score;
  Dog():p(point(0,0)),v(0.0),score(0){}
  Dog(point p, elem v):p(p),v(v),score(0){}
  void move(point target, double t){
    vec V = target - p;
    V = t * v * uvec(V);
    p = p + V;
  }
};

class Frisbee{
public:
  point p;
  vec v;
  Frisbee():p(point(0,0)),v(vec(0,0)){}
  Frisbee(point p, vec v):p(p),v(v){}
};

bool reachable(const Dog &dog, const Frisbee &fris, double &time)
{
  if(near(dog.p,fris.p)){time=0;return true;}
  vec A=vec(dog.p-fris.p);
  double a = pow(abs(dog.v),2.0)-pow(abs(fris.v),2.0);
  double b = dot(A,fris.v);
  double c = -pow(abs(A),2.0);
  double D = pow(b,2.0)-a*c;
  if( eq(a, 0.0) ){time=infty;return false;}
  if( lt(D, 0.0) ){time=infty;return false;}
  double t = (-b+sqrt(D))/a;
  if( lt(t, 0.0) ){
    return false;
  }
  time = t;
  return true;
}

int main(){
  while(true){
    int N;
    int M;
    //cout <<"START" << endl;
    cin >> N >> M;
    //cout << N << ' ' << M << endl;
    if( N == 0 && M == 0 ) break;
    vector<Dog> dogs;
    vector<Frisbee> fris;

    for(int i = 0; i < N; ++i){
      elem x,y,v;
      cin >> x >> y >> v;
      dogs.push_back( Dog(point(x,y),v) );
    }

    for(int i = 0; i < M; ++i){
      elem x,y,vx,vy;
      cin >> x >> y >> vx >> vy;
      fris.push_back( Frisbee( point(x,y), vec(vx,vy) ) );
    }
    
    for(int i = 0; i < M; ++i){
      elem min_time = infty;
      int min_dog = -1;
      bool reach[16];
      elem times[16];
      
      for(int j = 0; j < N; ++j){
	elem time;
	reach[j] = reachable( dogs[j], fris[i], time );
	if( reach[j] ){
	  if( lt(time,min_time) ){
	    min_time = time;
	    min_dog = j;
	  }
	}
	times[j] = time;
      }
      
      dogs[min_dog].score++;
      for(int j = 0; j < N; ++j){
	if( reach[j] ){
	  point T = ( times[j] * fris[i].v ) + fris[i].p;
	  //cout << times[j] << ' ' << " DISTANCE : " << abs(T-dogs[j].p) << ' ' << dogs[j].p << ' ' << T << endl;
	  dogs[j].move( T, min_time );

	  //cout << dogs[j].p << endl;
	}
      }
      
    }
    
    for(int i = 0; i < N; ++i){
      if( i > 0 ) cout << ' ';
      cout << dogs[i].score; 
    }
    cout << endl;
    //cout << "END" << endl;
  }
  return 0;
}