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

namespace ConsoleApp2
{
    class Program
    {
        static void sort(int[] a, int n)
        {
            int p;
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (a[i] > a[j])
                    {
                        p = a[i];
                        a[i] = a[j];
                        a[j] = p;
                    }

                }
            }
        }
        static void Citaj(out int[] d, out int[] u, out int[] l, out int[] r, out int[] x, out int n, out int m)
        {
            int[] c = new int[2];
            string[] s1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < 2; i++)
            {
                c[i] = int.Parse(s1[i]);
                
            }
            n = c[0];
            m = c[1];

            d = new int[n];
            u = new int[n];
            int k = 0;
            for(int j = 0; j < n; j++)
            {
                string[] s2 = Console.ReadLine().Split(' ');
                d[k] = int.Parse(s2[0]);
                u[k] = int.Parse(s2[1]);
                k++;
            }
            k = 0;
            l = new int[m];
            r = new int[m];
            x = new int[m];
            for (int j = 0; j < m; j++)
            {
                string[] s3 = Console.ReadLine().Split(' ');
                l[j] = int.Parse(s3[0]);
                r[j] = int.Parse(s3[1]);
                x[j] = int.Parse(s3[2]);
                k++;
            }

        }
        static void Stampaj(int[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(a[i]);
            }
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            int[] d, u, l, r, x;
            int n, m, k = 0, br = 0;
            Citaj(out d, out u, out l, out r, out x, out n, out m);
            for(int i = 0; i < m; i++)
            {
                for(int j = l[i] - 1; j <= r[i] - 1; j++)
                {
                    if(x[i] >= d[j] && x[i] <= u[j])
                    {
                        br++;
                    }
                }
                Console.WriteLine(br);
                br = 0;
            }
        }
    }
}