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

namespace ConsoleApp21
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string linija = Console.ReadLine();
            int n = int.Parse(linija.Split(' ')[0]);
            int m = int.Parse(linija.Split(' ')[1]);
            int[,] vage = new int[2, n];

           
            for (int i = 0; i < n; i++)
            {
                linija = Console.ReadLine();
                vage[0, i] = int.Parse(linija.Split(' ')[i]);
                vage[1, i] = int.Parse(linija.Split(' ')[i]);
               

            }
            int[] niz = new int[m];
            for (int i = 0; i < m; i++)
            {
                int l = int.Parse(linija.Split(' ')[0]);
                int r = int.Parse(linija.Split(' ')[1]);
                int x = int.Parse(linija.Split(' ')[2]);
                int br = 0;
                for (int j = l; j <= r; j++)
                {
                    if (vage[0, j] < x && vage[1, j] > x) br++;
                }
                niz[i] = br;
            }
            for (int i = 0; i < m; i++)
            {
                Console.WriteLine(niz[i]);
            }
        }
    }
}