using System;
using System.Text;

namespace kv1
{
    class Program
    {
        static int Upada(int[,] vage, int i1, int i2, int vrednost)
        {
            int zbir = 0;
            for (int i = i1 - 1; i < i2; i++)
            {
                if (vrednost < vage[i, 0] || vrednost > vage[i, 1]) continue;
                zbir++;
            }
            return zbir;
        }
        static void Main(string[] args)
        {
            string[] red = Console.ReadLine().Split();
            int vage = Convert.ToInt32(red[0]);
            int pitanja = Convert.ToInt32(red[1]);
            int[,] matrica = new int[vage, 2];
            for (int i = 0; i < vage; i++)
            {
                red = Console.ReadLine().Split();
                for (int j = 0; j < matrica.GetLength(1); j++)
                {
                    matrica[i, j] = Convert.ToInt32(red[j]);
                }
            }
            int[] rezultati = new int[pitanja];
            for (int i = 0; i < pitanja; i++)
            {
                red = Console.ReadLine().Split();
                rezultati[i] = Upada(matrica, Convert.ToInt32(red[0]), Convert.ToInt32(red[1]), Convert.ToInt32(red[2]));
            }
            foreach (int r in rezultati)
                Console.WriteLine(r);
        }
    }
}