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


namespace TakZad2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string [] FirstEntry = Console.ReadLine().Split(' ');

            int numStatement = int.Parse(FirstEntry[0]);
            int numQuestion = int.Parse(FirstEntry[1]);



            string[] Statements = new string[101];
            string[] Questions = new string[101];

            int Array1des = 1;

            for (int i = 1; i <= numStatement; i++)
            {
                string [] Array1 = Console.ReadLine().Split(' ');
                Array1.CopyTo(Statements, Array1des);
                Array1des += 2;
            }

            int Array2des = 1;

            for (int i = 1; i <= numQuestion; i++)
            { 
                string [] Array2 = Console.ReadLine().Split(' ');
                Array2.CopyTo(Questions, Array2des);
                Array2des += 3;
            }




           
            int Q1 = 1;
            int Q2 = 2;
            int QW = 3;

            int score = 0;

       
              for (int i = 1; i <= numQuestion; i++)
              {

                


                 int FirstNum = int.Parse(Questions[Q1]);
                 int SecondNum = int.Parse(Questions[Q2]);


                 int index = FirstNum; 
                 while (index >= FirstNum && index <= SecondNum)
                 {
                    int SWMAX = index * 2;
                    int SWMIN = index * 2 - 1;
                    int.Parse(Statements[SWMAX]);

                    if (int.Parse(Questions[QW]) <= int.Parse(Statements[SWMAX]) && int.Parse(Questions[QW]) >= int.Parse(Statements[SWMIN]))
                        score++;
                    
                    
                    index++;
                 }

                  Console.WriteLine(score);

                  Q1 += 3;
                  Q2 += 3;
                  QW += 3;

                  score = 0;
              }
               
            Console.ReadLine();
        }
    }
}