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 <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> VP;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0) break;

        VP dog(n);
        vector<double> v(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y >> v[i];
            dog[i] = P(x, y);
        }

        VP fp(m), dir(m);
        for(int i=0; i<m; i++){
            double xp,yp,xd,yd;
            cin >> xp >> yp >> xd >> yd;
            fp[i] = P(xp, yp);
            dir[i] = P(xd, yd);
        }

        vector<int> ans(n, 0);
        for(int i=0; i<m; i++){
            //座標変換(フリスビー位置を原点、投げる方向をx軸方向に)
            P bpos = fp[i];
            P bdir = dir[i]/abs(dir[i]);
            for(int j=0; j<n; j++){
                dog[j] -= bpos;
                dog[j] /= bdir;
            }
            for(int j=0; j<m; j++){
                fp[j] -= bpos;
                fp[j] /= bdir;
                dir[j] /= bdir;
            }

            vector<bool> run(n, false);
            VP rdir(n);
            double tmin = INF;
            int minidx = -1;
            //2次方程式を解く
            for(int j=0; j<n; j++){
                double a,b,c;
                a = 1 -(v[j]*v[j] /norm(dir[i]));
                b = -2 *dog[j].X;
                c = norm(dog[j]);
                double sol = INF;
                if(abs(a) < EPS){
                    if(abs(b) > EPS && -c/b > 0){
                        sol = -c/b;
                    }
                }else{
                    double d = b*b -4*a*c;
                    if(abs(d) < EPS) d = 0;
                    if(d >= 0){
                        double tmp[2] = {(-b+sqrt(d))/(2*a), (-b-sqrt(d))/(2*a)};
                        if(tmp[0] > 0) sol = min(sol, tmp[0]);
                        if(tmp[1] > 0) sol = min(sol, tmp[1]);
                    }
                }

                if(sol == INF) continue;
                run[j] = true;
                rdir[j] = P(sol, 0) -dog[j];
                rdir[j] *= v[j] /abs(rdir[j]);
                double time = sol/dir[i].X;
                if(time < tmin){
                    tmin = time;
                    minidx = j;
                }
            }
            for(int j=0; j<n; j++){
                if(run[j]){
                    dog[j] += tmin *rdir[j];
                }
            }
            if(minidx != -1){
                ans[minidx]++;
            }
        }

        for(int i=0; i<n-1; i++){
            cout << ans[i] << " ";
        }
        cout << ans[n-1] << endl;
    }
    return 0;
}