using System;
using static System.Console;

namespace ConsoleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string reader1 = ReadLine();
            string[] nq = reader1.Split(' ');
            long N = long.Parse(nq[0]); long Q = long.Parse(nq[1]);
            long[,] tabela = new long[N, 2];                  //start

            for (long i = 0; i < N; i++)
            {
                string reader2 = ReadLine();             //citac
                string[] n12 = reader2.Split(' ');
                tabela[i, 0] = long.Parse(n12[0]);
                tabela[i, 1] = long.Parse(n12[1]);
            }
            long[] k = new long[Q];
            for (long i = 0; i < Q; i++)
            {
                k[i] = long.Parse(Console.ReadLine());
            }


            long pojedeno = 0; long ima = 0; long id = 0;
            for (long dan = 1; dan <= k[Q - 1]; dan++)     //zapravo   
            {
                if (id < N && tabela[id, 0] == dan)
                {
                    ima += tabela[id, 1];
                    id++;
                }

                if (ima >= 1000000)
                {
                    ima -= 1000000;
                    pojedeno += 1000000;
                }
                
                if (ima > 0)
                {
                    ima--;                  //brojilo
                    pojedeno++;
                }

                for (long j = 0; j < Q; j++)
                {
                    
                    
                        if (k[j] == dan)
                        {
                            WriteLine(pojedeno);           //finish
                            break;
                        }
                    
                }
            }
        }
    }
}