namespace ConsoleApp24
{
    internal class Program
    {
        static void Main(string[] args)
        {


           
            var firstLine = Console.ReadLine().Split();
            int N = int.Parse(firstLine[0]); 
            int Q = int.Parse(firstLine[1]); 

           
            long[] d = new long[N];
            long[] p = new long[N];
            for (int i = 0; i < N; i++)
            {
                var purchase = Console.ReadLine().Split();
                d[i] = long.Parse(purchase[0]);  
                p[i] = long.Parse(purchase[1]);  
            }

          
            long[] queries = new long[Q];
            for (int i = 0; i < Q; i++)
            {
                queries[i] = long.Parse(Console.ReadLine());
            }

           
            long[] answers = new long[Q];

            
            var indexedQueries = queries.Select((q, idx) => new { Query = q, Index = idx }).OrderBy(x => x.Query).ToArray();

            
            for (int qIndex = 0; qIndex < Q; qIndex++)
            {
                long k = indexedQueries[qIndex].Query;
                long totalPacks = 0;

               
                int idx = Array.BinarySearch(d, k); 
                if (idx < 0)
                    idx = ~idx;  

                
                for (int i = 0; i < idx; i++)
                {
                    totalPacks += p[i]; 
                }

                answers[indexedQueries[qIndex].Index] = totalPacks;
            }

           
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }


        }
    }
}