
object Main extends App{
  import scala.io.StdIn._
  import scala.math._
  import scala.annotation.tailrec
  type Time = Int
  type UFO_Num = Int
  val (a::b::_) = readLine().trim().split(" ").map{_.toInt}.toList
  solve(a, b)
  @tailrec
  def solve(r:Int, n:Int):Unit = {
    if (n != 0 && r != 0) {
      println(f(Seq.tabulate(n){i => 
          val (x::y::rad::ver::_) = readLine().split(" ").map{_.toDouble}.toList
          UFO(x, y, rad, ver)
      }, r))
      val (na::nb::_) = readLine().trim().split(" ").map{_.toInt}.toList
      solve(na, nb)
      
    }
  }
  def f(ufos:Seq[UFO], radius:Int, time:Time = 0):Int = {
        if (ufos.size == 0) 0
        else {
          val result = shoot(ufos, time, radius)
          result._1 + f(result._2, radius, time + 1)
        }
      }
      def shoot(ufos:Seq[UFO], time:Time, invalidRadius:Int):(UFO_Num, Seq[UFO]) = {
        val sorted = ufos.sortBy(ufo => Vector(ufo.position(time)).length)
        val spaned = sorted.span(ufo => Vector(ufo.position(time)).length < invalidRadius)
        spaned._2 match{
          case Nil => (spaned._1.size, Seq.empty[UFO])
          case target::tail => 
            val razer = Vector(target.position(time)).angle
            (spaned._1.size, tail.filter{case ufo =>
              val ufo_pos = ufo.position(time)
              val sin = ufo.radius.toDouble / Vector(ufo_pos).length
              val perspective = Angle(sin, sqrt(1 - sin * sin))
              val center = Vector(ufo_pos).angle
              perspective - razer + center >= Angle(0, 1) && perspective + razer - center >= Angle(0, 1)  
            })
        }
      }
      case class Point(x:Double, y:Double)
      object Vector{
        def apply(from:Point, to:Point):Vector = new Vector(from.x - to.x, from.y - to.y)
        def apply(point:Point):Vector = new Vector(point.x, point.y)
      }
      class Vector(x:Double, y:Double){
        def angle:Angle = Angle(x, y)
        def length:Double = sqrt(x * x + y * y)
      }
      object Angle{
        def apply[A <% Double](x:A, y:A):Angle = {
          new Angle(y / sqrt(x * x + y * y), x / sqrt(x * x + y * y))
        }
      }
      case class Angle(sin:Double, cos:Double) extends Ordered[Angle] {
        def +(that:Angle):Angle = new Angle(sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin)
        def -(that:Angle):Angle = new Angle(sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin)
        def compare(that:Angle):Int = toRadian.compare(that.toRadian)
        private def toRadian:Double = if (sin >= 0) acos(cos) else Pi * 2 - acos(cos)
      }
      case class UFO(x:Double, y:Double, radius:Double, velocity:Double){
        lazy val reachTime = sqrt(x * x + y * y) / velocity
        def position[A <% Double](t:A):Point = Point(x - x * t / reachTime, y - y * t / reachTime)
      }
}
