using System;

namespace MyApp // Note: actual namespace depends on the project name.
{
    internal class Program
    {
        struct Vaga
        {
            public int indeks;
            public int minkilaza;
            public int maxkilaza;
        }

        struct Pitanje
        {
            public int indeksod;
            public int indeksdo;
            public int kilaza;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int brVagi = int.Parse(s[0]);
            int brPitanja = int.Parse(s[1]);
            Vaga[] vaga = new Vaga[brVagi];
            Pitanje pitanje;
            

            for (int i = 0; i < brVagi; i++)
            {
                string[] s2 = Console.ReadLine().Split();
                vaga[i].indeks = i + 1;
                vaga[i].minkilaza = int.Parse(s2[0]);
                vaga[i].maxkilaza = int.Parse(s2[1]);
            }
            int[] resenje = new int[brPitanja];
            for (int i = 0; i < brPitanja; i++)
            {
                string[] s2 = Console.ReadLine().Split();
                pitanje.indeksod = int.Parse(s2[0]);
                pitanje.indeksdo = int.Parse(s2[1]);
                pitanje.kilaza = int.Parse(s2[2]);
                resenje[i] = Resi(pitanje, vaga);
            }
            for (int i = 0; i < resenje.Length; i++)
            {
                Console.WriteLine(resenje[i]);
            }

        }

        private static int Resi(Pitanje pitanje, Vaga[] vaga)
        {
            int brojac = 0;
            for (int i = 0; i < vaga.Length; i++)
            {
                if (vaga[i].indeks >= pitanje.indeksod && vaga[i].indeks <= pitanje.indeksdo)
                {
                    if (vaga[i].maxkilaza >= pitanje.kilaza && vaga[i].minkilaza <= pitanje.kilaza)
                    {
                        brojac++;
                    }
                }
            }
            return brojac;
        }
    }
}