using System;
using System.Collections.Generic;

namespace vage
{
    class Program
    {
        static List<Tuple<long, long>> vaga = new List<Tuple<long, long>>();

        static int racun(long a, long b, long x)
        {
            if (a > b) return 0;
            else
            {
                if (x >= vaga[(int)a].Item1 && x <= vaga[(int)a].Item2) return 1 + racun(a + 1, b, x);
                else return racun(a + 1, b, x);
            }
        }

        static void Main(string[] args)
        {
            string[] unos1 = Console.ReadLine().Split();
            int n = int.Parse(unos1[0]);
            int m = int.Parse(unos1[1]);

            for (int i = 0; i < n; i++)
            {
                string[] unos2 = Console.ReadLine().Split();
                vaga.Add(Tuple.Create(long.Parse(unos2[0]), long.Parse(unos2[1])));
            }

            List<Tuple<long, long, long>> pitanja = new List<Tuple<long, long, long>>();
            for(int i = 0; i < m; i++)
            {
                string[] unos3 = Console.ReadLine().Split();
                pitanja.Add(Tuple.Create(long.Parse(unos3[0]) - 1, long.Parse(unos3[1]) - 1, long.Parse(unos3[2])));
            }

            for(int i = 0; i < m; i++)
            {
                Console.WriteLine(racun(pitanja[i].Item1, pitanja[i].Item2, pitanja[i].Item3));
            }
        }
    }
}