fun main(args:Array<String>?): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    var xs = IntArray(n) { 0 }
    var ys = IntArray(n) { 0 }
    val points = Array(n) {
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        xs[it] = x
        ys[it] = y
        Point(x, y)
    }
    xs.sort()
    ys.sort()
    xs = xs.distinct().toIntArray()
    ys = ys.distinct().toIntArray()
    val sum = Array(ys.size) { IntArray(xs.size) { 0 } }
    for ((x, y) in points) {
        sum[ys.binarySearch(y)][xs.binarySearch(x)]++
    }
    for (i in sum.indices) for (j in sum[i].indices){
        if (i > 0) sum[i][j] += sum[i - 1][j]
        if (j > 0) sum[i][j] += sum[i][j - 1]
        if (i > 0 && j > 0) sum[i][j] -= sum[i - 1][j - 1]
    }
    repeat(m){
        val (left, up, right, bottom) = readLine()!!.trim().split(' ').map(String::toInt)
        val lx =lowerBound(xs, left) - 1
        val uy = lowerBound(ys, up) - 1
        val rx = upperBound(xs, right) - 1
        val dy = upperBound(ys, bottom) - 1
        if (rx >= 0 && dy >= 0) {
            var result = sum[dy][rx]
            if (lx >= 0) result -= sum[dy][lx]
            if (uy >= 0) result -= sum[uy][rx]
            if (lx >= 0 && uy >= 0) result += sum[uy][lx]
            println(result)
        }else {
            println(0)
        }
    }
}
fun upperBound(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right) {
        val mid = (left + right) / 2
        if (array[mid] <= target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}
fun lowerBound(array: IntArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] < target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}
data class Point(val x: Int, val y: Int)
