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

namespace Takmicenje
{
    class Program
    {
        static void Main(string[] args)
        {

            string t = Console.ReadLine();
            int[,] n = new int[int.Parse(t.Split(' ')[0]), 2];
            int[,] m = new int[int.Parse(t.Split(' ')[1]), 3];
            string tm = Console.ReadLine();
            string tmm = Console.ReadLine();
            for (int i = 0; i < n.GetLength(0); i++)
            {
                for (int j = 0; j < n.GetLength(1); j++)
                {
                    if (j == 0)
                        n[i, j] = int.Parse(tm.Split(' ')[0]);
                    else
                        n[i, j] = int.Parse(tm.Split(' ')[1]);
                }
            }
            for (int i = 0; i < m.GetLength(0); i++)
            {
                for (int j = 0; j < m.GetLength(1); j++)
                {
                    if (j == 0) m[i, j] = int.Parse(tmm.Split(' ')[0]);
                    if (j == 1) m[i, j] = int.Parse(tmm.Split(' ')[1]);
                    if (j == 2) m[i, j] = int.Parse(tmm.Split(' ')[2]);
                }
            }

            int brojac = 0;
            for (int i = 0; i < m.GetLength(0); i++)
            {
                brojac = 0;
                for (int j = (m[i, 0] - 1); j <= (m[i, 1] - 1); j++)
                {
                    if (m[i, 2] <= n[j, 0] && m[i, 2] >= n[j, 1])
                        brojac++;
                }
                Console.WriteLine(brojac);
            }
        }
    }
}