using System;

namespace Zadatak_04_Vage
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m, i;
            string[] s = Console.ReadLine().Split();
            n = Convert.ToInt32(s[0]);
            m = Convert.ToInt32(s[1]);
            int[] d = new int[n];
            int[] u = new int[n];
            int[] l = new int[m];
            int[] r = new int[m];
            int[] x = new int[m];
            for (i = 0; i < n; i++)
            {
                s = Console.ReadLine().Split();
                d[i] = Convert.ToInt32(s[0]);
                u[i] = Convert.ToInt32(s[1]);
            }
            for (i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split();
                l[i] = Convert.ToInt32(s[0]);
                r[i] = Convert.ToInt32(s[1]);
                x[i] = Convert.ToInt32(s[2]);
            }
            for (i = 0; i < m; i++)
            {
                Console.WriteLine(OdgovorNaPitanje(d, u, l[i], r[i], x[i]));
            }

            
        }

        static int OdgovorNaPitanje(int[] d, int[] u, int l, int r, int x)
        {
            int a = 0, i;
            for (i = l - 1; i <= r - 1; i++)
            {
                if(d[i] <= x && x <= u[i])
                {
                    a++;
                }
            }
            return a;
        }
    }
}