object Main extends App {

  import scala.io.StdIn._

  val Array(w, h, t) = readLine.trim.split(' ').map(_.toInt)
  val schedule = Array.tabulate(readLine.trim.toInt){_ ⇒
    val Array(x, y, _) = readLine.trim.split(' ').map(_.toInt)
    Coordinate(x, y)
  }
  val state = Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toInt == 1)}
  println(
    schedule.count(p ⇒ state(p.y)(p.x))
  )
  case class Coordinate(x: Int, y: Int)
}

