#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

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

const double EPS = 1e-8;

struct Ufo {
    Ufo(int a, int b, int c, int d) {
        x0 = a, y0 = b, r = c, v = d;
        dist0 = dist = std::sqrt(a * a + b * b);
    }
    int x0, y0, r, v;
    double dist0, dist;
    bool operator<(const Ufo& tar) const { return dist > tar.dist; }
};

int main() {
    std::vector<Ufo> ens;
    int r, n;
    while (std::cin >> r >> n && r && n) {
        rep(i, n) {
            int a, b, c, d;
            std::cin >> a >> b >> c >> d;
            ens.push_back(Ufo(a, b, c, d));
        }

        int count = 0;
        while (true) {
            std::cout << std::endl;

            for (auto& e : ens) e.dist -= e.v;
            std::sort(ens.begin(), ens.end());

            for (auto e : ens)
                std::cout << e.x0 << ',' << e.y0 << ' ' << e.dist << ' ' << e.r
                          << std::endl;

            while (ens.size() && ens.back().dist <= r) {
                std::cout << "entered" << std::endl;
                count++;
                ens.pop_back();
            }
            if (ens.size() == 0) break;

            int px = ens.back().x0, py = ens.back().y0;
            ens.pop_back();
            for (auto it = ens.begin(); it != ens.end();) {
                double p = it->dist * it->x0 / it->dist0;
                double q = it->dist * it->y0 / it->dist0;
                if ((px * p + py * q) / it->dist > r - EPS &&
                    std::abs(py * p - px * q) / it->dist0 < it->r + EPS) {
                    std::cout << std::abs(py * p - px * q) / it->dist0 << ' '
                              << it->r << " erase" << std::endl;
                    it = ens.erase(it);
                } else
                    it++;
            }
        }
        std::cout << count << std::endl;

        ens.clear();
    }
}