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

namespace Vage
{
    internal class Program
    {
        struct granice
        {
            public int min;
            public int max;
        }
        struct pitanja
        {
            public int prvav;
            public int drugav;
            public int težina;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            granice[] a = new granice[n];
            for (int i = 0; i < n; i++)
            {
                s = Console.ReadLine().Split();
                a[i].min = int.Parse(s[0]);
                a[i].max = int.Parse(s[1]);
            }
            pitanja[] b = new pitanja[m];
            for (int i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split();
                b[i].prvav = int.Parse(s[0]);
                b[i].drugav = int.Parse(s[1]);
                b[i].težina = int.Parse(s[2]);
            }
            for (int i = 0; i < m; i++)
            {
                int br = 0;
                while (b[i].prvav <= b[i].drugav)
                {
                    int w = b[i].prvav - 1;
                    if (a[w].min <= b[i].težina && a[w].max >= b[i].težina) br++;
                    b[i].prvav++;
                }
                Console.WriteLine(br);
            }
        }
    }
}