#include <algorithm>
#include <array>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <utility>
#include <vector>

template <typename Integral,
	std::size_t bitsize = std::numeric_limits<Integral>::digits()>
	class WaveletMatrix {
	public:
		using value_type = Integral;
		using size_type = std::size_t;

	private:
		using uint32 = std::uint_least32_t;
		static size_type popcount32(uint32 c) {
#ifdef __GNUC__
			return __builtin_popcount(c);
#elif _MSC_VER_
			return _mm_popcnt_u32(c);
#else
			c = (c & 0x55555555) + ((c >> 1) & 0x55555555);
			c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
			c = (c + (c >> 4)) & 0x0F0F0F0F;
			c += c >> 8;
			c += c >> 16;
			return static_cast<size_type>(c) & 0x3F;
#endif
		}
		struct FID {
			std::vector<uint32> dic;
			size_type cnt;
			value_type bit;
			FID() {}
			FID(const size_type bsize) : dic(bsize, 0) {}
			void set(const size_type index) {
				dic[index >> 4 | 1] |= static_cast<uint32>(1) << (index & 0x1f);
			}
			void build() {
				const size_type len = dic.size();
				for (size_type j = 2; j < len; j += 2)
					dic[j] = dic[j - 2] + popcount32(dic[j - 1]);
			}
			size_type rank(const size_type last) const {
				return static_cast<size_type>(
					dic[last >> 4 & ~static_cast<size_type>(1)]) +
					popcount32(dic[last >> 4 | 1] &
					(static_cast<size_type>(1) << (last & 0x1f)) - 1);
			}
			bool access(const size_type index) const {
				return dic[index >> 4 | 1] >> (index & 0x1f) & 1;
			}
		};
		std::array<FID, bitsize> matrix;
		value_type NOT_FOUND;
		size_type size_;

	public:
		WaveletMatrix(std::vector<value_type> data, const value_type NOT_FOUND = 0)
			: size_(data.size()), NOT_FOUND(NOT_FOUND) {
			const size_type len = data.size(), block = ((len >> 5) + 1) << 1;
			std::vector<value_type> L(len), R(len);
			size_type l, r;
			value_type temp = static_cast<value_type>(1) << (bitsize - 1);
			for (auto &x : matrix) {
				x = FID(block);
				x.bit = temp;
				temp = temp >> 1 & ~temp;
				l = 0;
				r = 0;
				for (size_type j = 0; j < len; ++j)
					if (data[j] & x.bit)
						R[r++] = data[j], x.set(j);
					else
						L[l++] = data[j];
				x.cnt = l;
				x.build();
				std::swap(data, L);
				std::copy(R.begin(), R.begin() + r, data.begin() + l);
			}
		}

		size_type size() const noexcept { return size_; }
		bool empty() const noexcept { return size() == 0; }

		value_type access(size_type index) const {
			assert(index < size());
			value_type ret = 0;
			for (const auto &x : matrix)
				if (x.access(index))
					ret |= x.bit, index = x.rank(index) + x.cnt;
				else
					index -= x.rank(index);
			return ret;
		}
		value_type operator[](const size_type index) const {
			assert(index < size());
			return access(index);
		}
		size_type rank(size_type first, size_type last, const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			for (const auto &x : matrix)
				if (data & x.bit)
					first = x.rank(first) + x.cnt, last = x.rank(last) + x.cnt;
				else
					first -= x.rank(first), last -= x.rank(last);
			return last - first;
		}
		value_type quantile(size_type first, size_type last, size_type k) const {
			assert(first < size());
			assert(last <= size());
			assert(first < last);
			assert(last - first > k);
			value_type ret = 0;
			for (const auto &x : matrix) {
				const size_type l = x.rank(first), r = x.rank(last);
				if (r - l > k)
					first = l + x.cnt, last = r + x.cnt, ret |= x.bit;
				else
					first -= l, last -= r, k -= r - l;
			}
			return ret;
		}
		value_type rquantile(size_type first, size_type last, size_type k) const {
			assert(first < size());
			assert(last <= size());
			assert(first < last);
			assert(last - first > k);
			return quantile(first, last, last - first - k - 1);
		}
		size_type less_than(size_type first, size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			size_type ret = 0;
			for (const auto &x : matrix) {
				if (data & x.bit) {
					ret += last - first + x.rank(first) - x.rank(last);
					first = x.rank(first) + x.cnt;
					last = x.rank(last) + x.cnt;
				}
				else {
					first -= x.rank(first);
					last -= x.rank(last);
				}
			}
			return ret;
		}
		size_type at_least(size_type first, size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			size_type ret = 0;
			for (const auto &x : matrix) {
				if (data & x.bit) {
					first = x.rank(first) + x.cnt;
					last = x.rank(last) + x.cnt;
				}
				else {
					ret += x.rank(last) - x.rank(first);
					first -= x.rank(first);
					last -= x.rank(last);
				}
			}
			return ret + (last - first);
		}
		size_type greater_than(size_type first, size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			size_type ret = 0;
			for (const auto &x : matrix) {
				if (data & x.bit) {
					first = x.rank(first) + x.cnt;
					last = x.rank(last) + x.cnt;
				}
				else {
					ret += x.rank(last) - x.rank(first);
					first -= x.rank(first);
					last -= x.rank(last);
				}
			}
			return ret;
		}
		size_type at_most(size_type first, size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			size_type ret = 0;
			for (const auto &x : matrix) {
				if (data & x.bit) {
					ret += last - first + x.rank(first) - x.rank(last);
					first = x.rank(first) + x.cnt;
					last = x.rank(last) + x.cnt;
				}
				else {
					first -= x.rank(first);
					last -= x.rank(last);
				}
			}
			return ret + (last - first);
		}
		size_type rangefreq(size_type first, size_type last, const value_type lower,
			const value_type upper) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			assert(lower <= upper);
			return at_least(first, last, lower) - at_least(first, last, upper);
		}
		value_type successor(const size_type first, const size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			const size_type k = at_least(first, last, data);
			return k ? quantile(first, last, k - 1) : NOT_FOUND;
		}
		value_type predecessor(const size_type first, const size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			const size_type k = greater_than(first, last, data);
			return last - first == k ? NOT_FOUND : quantile(first, last, k);
		}
		value_type strict_succ(const size_type first, const size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			const size_type k = greater_than(first, last, data);
			return k ? quantile(first, last, k - 1) : NOT_FOUND;
		}
		value_type strict_pred(const size_type first, const size_type last,
			const value_type data) const {
			assert(first <= size());
			assert(last <= size());
			assert(first <= last);
			const size_type k = at_least(first, last, data);
			return last - first == k ? NOT_FOUND : quantile(first, last, k);
		}
};
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <functional>
#include <iterator>
#include <memory>
#include <utility>
#include <vector>

template <class T>
using StaticMultiSetDefaultContainer = std::vector<T, std::allocator<T>>;

template <class T = std::int_fast64_t,
	template <class> class Container = StaticMultiSetDefaultContainer,
	class Compare = std::less<typename Container<T>::value_type>>
	class StaticMultiSet {
	public:
		using container_type = Container<T>;
		using value_compare = Compare;
		using value_type = typename container_type::value_type;
		using reference = typename container_type::const_reference;
		using const_reference = typename container_type::const_reference;
		using size_type = typename container_type::size_type;
		using difference_type = typename container_type::difference_type;
		using pointer = typename container_type::const_pointer;
		using const_pointer = typename container_type::const_pointer;
		class const_iterator : public std::random_access_iterator_tag {
			friend StaticMultiSet;

		private:
			using iterator_type = typename container_type::const_iterator;
			iterator_type it;
			difference_type order_;
			explicit const_iterator(iterator_type x, difference_type y)
				: it(x), order_(y) {}

		public:
			const_reference operator*() const { return *it; }
			const_pointer operator->() const { return std::addressof(operator*()); }
			const_reference operator[](difference_type n) const { return it[n]; }

			const_iterator &operator++() {
				++it, ++order_;
				return *this;
			}
			const_iterator operator++(int) {
				auto ret = *this;
				operator++();
				return ret;
			}
			const_iterator &operator--() {
				--it, --order_;
				return *this;
			}
			const_iterator operator--(int) {
				auto ret = *this;
				operator--();
				return ret;
			}
			const_iterator &operator+=(difference_type n) {
				it += n, order_ += n;
				return *this;
			}
			const_iterator operator+(difference_type n) const {
				return const_iterator(it + n, order_ + n);
			}
			const_iterator &operator-=(difference_type n) {
				it -= n, order_ -= n;
				return *this;
			}
			const_iterator operator-(difference_type n) const {
				return const_iterator(it - n, order_ - n);
			}

			bool operator==(const const_iterator &other) const {
				return it == other.it;
			}
			bool operator!=(const const_iterator &other) const {
				return it != other.it;
			}
			bool operator<(const const_iterator &other) const { return it < other.it; }
			bool operator<=(const const_iterator &other) const {
				return it != other.it;
			}
			bool operator>(const const_iterator &other) const { return it > other.it; }
			bool operator>=(const const_iterator &other) const {
				return it >= other.it;
			}

			const_reference value() const { return *it; }
			difference_type order() const { return order_; }
		};
		using iterator = const_iterator;

	protected:
		container_type c;
		value_compare comp;

	private:
		iterator make_itr(const typename iterator::iterator_type &it) {
			return iterator(it, std::distance(c.cbegin(), it));
		}
		const_iterator
			make_citr(const typename const_iterator::iterator_type &it) const {
			return const_iterator(it, std::distance(c.cbegin(), it));
		}

	public:
		StaticMultiSet() : c(), comp() {}
		explicit StaticMultiSet(const value_compare &x) : comp(x) {}
		explicit StaticMultiSet(const value_compare &x, const container_type &other)
			: c(other), comp(x) {
			build();
		}
		explicit StaticMultiSet(const value_compare &x, container_type &&other)
			: c(std::move(other)), comp(x) {
			build();
		}

		iterator begin() { return make_itr(c.cbegin()); }
		iterator end() { return make_itr(c.cend()); }
		const_iterator cbegin() const { return make_citr(c.cbegin()); }
		const_iterator cend() const { return make_citr(c.cend()); }

		size_type size() const { return c.size(); }
		bool empty() const { return c.empty(); }
		void reserve(const size_type s) { c.reserve(s); }
		void shrink_to_fit() { c.shrink_to_fit(); }

		const_reference operator[](const size_type order) const {
			assert(order < size());
			return c[order];
		}
		const_reference at(const size_type order) const { return c.at(order); }
		const_reference min() const {
			assert(!empty());
			return c.front();
		}
		const_reference max() const {
			assert(!empty());
			return c.back();
		}
		const_iterator succ(const value_type &x) const {
			return make_citr(std::lower_bound(c.cbegin(), c.cend(), x, comp));
		}
		const_iterator pred(const value_type &x) const {
			return make_citr(std::upper_bound(c.cbegin(), c.cend(), x, comp) - 1);
		}
		const_iterator strict_succ(const value_type &x) const {
			return make_citr(std::upper_bound(c.cbegin(), c.cend(), x, comp));
		}
		const_iterator strict_pred(const value_type &x) const {
			return make_citr(std::lower_bound(c.cbegin(), c.cend(), x, comp) - 1);
		}

		void push(const value_type &x) { c.push_back(x); }
		void push(value_type &&x) { c.push_back(std::move(x)); }
		template <class... Args> void emplace(Args &&... args) {
			c.emplace_back(std::forward<Args>(args)...);
		}
		void build() {
			std::sort(c.begin(), c.end(), comp);
		}
		void clear() { c.clear(); }
};

#include<algorithm>
#include<iostream>
#include<vector>
#include<utility>
int main() {
	constexpr int base = 1000000000;
	using P = std::pair<int, int>;
	int n, m;
	std::cin >> n >> m;
	StaticMultiSet<P> s;
	s.reserve(n);
	while (n--) {
		int x, y;
		std::cin >> x >> y;
		y += base;
		s.emplace(x, y);
	}
	s.build();
	std::vector<int> a;
	for (const auto &e : s)
		a.emplace_back(e.second);
	WaveletMatrix<int, 31> W(a);
	while (m--) {
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;
		c++;
		d++;
		b += base;
		d += base;
		std::cout << W.rangefreq(s.succ(P(a,0)).order(), s.succ(P(c,0)).order(), b, d) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3232