fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        val (x, y, w, h) = readLine()!!.trim().split(' ').map(String::toInt)
        val square = Square(Point(x, y), w, h)
        println(Array(readLine()!!.trim().toInt()){
            val (cx, cy) = readLine()!!.trim().split(' ').map(String::toInt)
            Point(cx, cy)
        }.count{square.isInArea(it)})
    }
}
data class Point(val x:Int, val y:Int)
class Square(leftBottom:Point, width:Int, height:Int){
    private val mXrange = leftBottom.x .. (leftBottom.x + width)
    private val mYrange = leftBottom.y .. (leftBottom.y + height)
    fun isInArea(point:Point):Boolean = point.x in mXrange && point.y in mYrange
}
