object Main {
    def main(args: Array[String]) {
        var factors     = Array[Int]()
        var train_point = Array[Array[Int]]()
        var questions   = Array[Array[Int]]()
        
        var count         = 0
        for(line <- io.Source.stdin.getLines()) {
            if(count == 0) {
                factors       = line.split(" ").map{_.toInt}
            }
            else if(1 <= count && count <= factors(1)) {
                train_point = train_point :+ line.split(" ").map{_.toInt}.sorted
            }
            else {
                questions = questions :+ line.split(" ").map{_.toInt}.sorted
            }

            count += 1
        }

        questions.foreach {i => 
            var answer_count = 0
            train_point.foreach {j =>
                if(i(0) <= j(0) && j(1) <= i(1)) { 
                    answer_count += 1
                }
            }
            println(answer_count)

        }
    }
}