using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace zadatak_D
{
    internal class Program
    {
        static int KolikoVagaMeri(int prviInd, int drugiInd, int kg, int[,] vage)
        {
            int br = 0;
            for (int i = prviInd - 1; i <= drugiInd - 1; i++)
            {
                if (kg >= vage[i, 0] && kg <= vage[i, 1])
                    br++;
            }
            return br;
        }
        static void Main(string[] args)
        {
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);
            int[,] vage = new int[n, 2];
            
            for (int i = 0; i < n; i++)
            {
                string[] svage = Console.ReadLine().Split();
                for (int j = 0; j < 2; j++)
                {
                    vage[i, j] = int.Parse(svage[j]);
                }
            }

            for (int i = 0; i < m; i++)
            {
                string[] pitanja = Console.ReadLine().Split();
                int prviInd = int.Parse(pitanja[0]);
                int drugiInd = int.Parse(pitanja[1]);
                int kg = int.Parse(pitanja[2]);
                int brVaga = KolikoVagaMeri(prviInd, drugiInd, kg, vage);
                Console.WriteLine(brVaga);
            }

        }
    }
}