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

namespace Plazma
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string linija = Console.ReadLine();
            Int64 N = Int64.Parse(linija.Split(' ')[0]+"");
            int Q = int.Parse(linija.Split(' ')[1]+"");
            Int64 ukupnaSuma = 0;
            Dictionary<Int64, Int64> map = new Dictionary<Int64, Int64>();
            for(int i = 1; i <= N; i++)
            {
                linija = Console.ReadLine();
                Int64 a = Int64.Parse(linija.Split(' ')[0] + "");
                Int64 b = Int64.Parse(linija.Split(' ')[1] + "");
                map[a] = b;
                ukupnaSuma += b;
            }
            
            List<Int64> listaPitanja = new List<Int64>();
            for(int i = 1; i <= Q; i++)
            {
                Int64 a = Int64.Parse(Console.ReadLine() + "");
                listaPitanja.Add(a);
                
            }
            foreach(Int64 dan in listaPitanja)
            {
                if (dan >= ukupnaSuma) { Console.WriteLine(ukupnaSuma); continue; }

                Int64 suma = 0;
                Int64 sumaPlazmi =0;
                Int64 br = 1;
                while (br <= dan)
                {
                    if (map.ContainsKey(br))
                    {
                        sumaPlazmi += map[br];
                        //map.Remove(br);
                    }
                    if (sumaPlazmi != 0) { suma++;sumaPlazmi--; }
                    br++;
                }
                Console.WriteLine(suma);
            }
        }
    }
}