using System;

class Program
{
    static void Main()
    {
        string[] input_raw_NQ = Console.ReadLine().Split(' ');
        int N = int.Parse(input_raw_NQ[0]);
        int Q = int.Parse(input_raw_NQ[1]);

        long[] days_of_purchase = new long[N];
        long[] amount_of_purchase = new long[N];  
        for (int i = 0; i < N; i++)
        {
            string[] current_day_and_purchase = Console.ReadLine().Split(' ');
            days_of_purchase[i] = long.Parse(current_day_and_purchase[0]);
            amount_of_purchase[i] = long.Parse(current_day_and_purchase[1]);
            
        }
        long[] questions = new long[Q];
        for (int i = 0; i < Q;  i++)
        {
            questions[i] = long.Parse(Console.ReadLine());
        }
        long[] results = new long[Q];
        for (int i = 0; i < Q; i++)
        {
            long amount = 0;
            int x = 0;
            long index = 0;
            for (int y = 0; y <= questions[i]; y++)
            {
                
                if (y == days_of_purchase[x])
                {
                    amount += amount_of_purchase[x];
                    x++;
                    if (x == days_of_purchase.Length)
                        x--;
                }
                if (amount > 0)
                {
                    index++;
                    amount--;
                }

            }
            results[i] = index;
        }
        
       for (int i = 0; i < Q;i++) 
       {
            Console.WriteLine(results[i]);
       }
       Console.ReadLine();


    }
}