using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string in1 = Console.ReadLine();
            string[] a = in1.Split();
            int n = int.Parse(a[0]);
            int q = int.Parse(a[1]);
            int[] red = new int[n];
            int[] pak = new int[n];
            long[] qu = new long[q];
            for(int i = 0; i < n; i++)
            {
                string str = Console.ReadLine();
                string[] strs = str.Split();
                red[i] = int.Parse(strs[0]) - 1;
                pak[i] = int.Parse(strs[1]);
            }
            for(int j = 0; j < q; j++)
            {
                qu[j] = long.Parse(Console.ReadLine());
            }
            long output = 0;
            bool flag = false;
            for(int i = 0; i < qu.Length; i++)
            {
                long supply = 0; int index = 0;
                for(int j = 0; j < qu[i]; j++)
                {
                    if (index < red.Length)
                    {
                        if (j == red[index])
                        {
                            supply += pak[index];
                            index++;
                        }
                        if(index == red.Length)
                        {
                            flag = true;
                        }
                    }
                    if(supply > 0)
                    {
                        output++;
                        supply--;
                    }
                    if (flag && qu[i] > supply)
                    {
                        output += supply;
                        break;
                    }
                }
                Console.WriteLine(output);
                output = 0;
            }
        }
    }
}