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

namespace Plazma
{
    internal class Program
    {
        static void Main(string[] args)
        {  
            string[] pods = new string[2];
            int raspolozivost = 0;
            int brojdana = 0;
            pods=Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(pods[0]);
            int Q=Convert.ToInt32(pods[1]);
            string[] arg = new string[2];
            int[]d= new int[N];
            int[]p= new int[N];
            long[]k= new long[Q];
            for (int i = 0; i < N; i++) 
            {
                arg=Console.ReadLine().Split(' ');
                d[i]= Convert.ToInt32(arg[0]);
                p[i]= Convert.ToInt32(arg[1]);
                raspolozivost += p[i];
                brojdana += d[i];
            }
            BubbleSort(d);
            BubbleSort(p);
            for (int i = 0; i < Q; i++)
            {
                k[i]= Convert.ToInt64(Console.ReadLine());
                for(int j = 0; j < k[i]; j++) 
                {
                    raspolozivost--;
                    brojdana++;
                    if(raspolozivost != 0) 
                    {
                        brojdana--;
                    }
                    else if(raspolozivost == 0) 
                    {
                        brojdana--;
                    }
                   
                }
                k[i] = brojdana-1;
            }
            
            for (int i = 0; i < Q; i++) 
            {
                Console.WriteLine(k[i]);
            }
            Console.ReadKey();
            
            
        }
        static void BubbleSort(int[] y) 
        {
            for (int i = 0; i < y.Length; i++) 
            {
                for (int j = 0; j < y.Length-i-1; j++) 
                { 
                    if(y[j] > y[j+1]) 
                    {
                        int pom=y[j];
                        y[j] = y[j+1];
                        y[j+1] = pom;
                    }
                }
            }
           
            
        }
    }
}