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

namespace takmicenje
{
    class Program
    {
        static int funkcija(int k,List<long> dani,long q)
        {
            int ima = 0;
            int nema = 0;
            for(int i = 0; i <= k; i++)
            {
                while (dani[i]>0)
                {
                    if(ima+nema==q)
                    {
                        return ima;
                    }
                    if(i%2==0)
                    {
                        nema++;
                        dani[i]--;
                    }
                    else
                    {
                        ima++;
                        dani[i]--;
                    }
                }
            }
            return ima;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n=int.Parse(s[0]);
            int q=int.Parse(s[1]);
            List<long> d = new List<long>();
            List<long> p = new List<long>();
            for(int i=0;i<n;i++)
            {
                s=Console.ReadLine().Split();
                d.Add(long.Parse(s[0]));
                p.Add(long.Parse(s[1]));
            }
            bool idk;
            int br=p.Count;
            do
            {
                idk = false;
                for (int i = 2; i <= d.Count; i++)
                {
                    if (p[i - 2] + d[i-2]-1 >= d[i-1])
                    {
                        long tempa = d[i - 2];
                        long tempb = p[i - 2] + p[i-1];
                        d[i - 2] = tempa;
                        p[i - 2] = tempb;
                        d.RemoveAt(i - 1);
                        p.RemoveAt(i - 1);
                        i--;
                        idk = true;
                        break;
                    }
                }
            }
            while (idk);
            List<long> dani = new List<long>();
            dani.Add(d[0] - 1);
            dani.Add(p[0]);
            int k = 2;
            for(int i=1;i<d.Count;i++)
            {

                dani.Add(d[i] - p[i - 1] - d[i - 1]);
                dani.Add(p[i]);
                k += 2;
            }
            long[] andjelina = new long[q];
            for(int i=0;i<q;i++)
            {
                andjelina[i]=long.Parse(Console.ReadLine());
            }
            for(int w=0;w<q;w++)
            {
                dani.Add(andjelina[w]);
                k++;
                int resenje = funkcija(k, dani, andjelina[w]);
                Console.WriteLine(resenje);
            }
        }
    }
}