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

namespace takmicenjeprvi
{
    internal class Program
    {
        static int[,] UnosTezinaVage(int N)
        {
            int[,] tezine = new int[N,2];
            for (int i = 0; i < N; i++)
            {
                string red = Console.ReadLine();
                string[]pomocni = red.Split();
                for (int j = 0; j < 2; j++)
                {
                    tezine[i, j] = int.Parse(pomocni[j]);
                }
            }
            return tezine;
        }
        static int[,] UnosPitanja(int M)
        {
            int[,]pitanja = new int[M,3];
            for (int i = 0;i < M; i++)
            {
                string red = Console.ReadLine();
                string[] pomocni = red.Split();
                for (int j = 0; j < 3; j++)
                {
                    pitanja[i, j] = int.Parse(pomocni[j]);
                }
            }
            return pitanja;
        }
        static void OdgovoriNaPitanja(int[,]tezine, int[,]pitanja)
        {
            int brojac = 0;
            for (int i = 0; i < pitanja.GetLength(0); i++)
            {
                for (int j = pitanja[i,0]; j <= pitanja[i,1]; j++)
                {
                    if (tezine[j - 1, 0] <= pitanja[i, 2] && tezine[j - 1, 1] >= pitanja[i, 2]) brojac++;
                }
                Console.WriteLine(brojac);
                brojac = 0;
            }  
        }
        static void Main(string[] args)
        {
          string unos = Console.ReadLine();
          string[] MN = unos.Split();
          int[,] tezine = UnosTezinaVage(int.Parse(MN[0]));
          int [,]pitanja = UnosPitanja(int.Parse(MN[1]));
          OdgovoriNaPitanja(tezine, pitanja);
        }
    }
}