using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

class Program
{





    static void Main()
    {
        string []ulaz = Console.ReadLine().Split();
        int n=int.Parse(ulaz[0]);
        int q=int.Parse(ulaz[1]);
       
        int[] d = new int[n];
        int[] p = new int[n];
        int[] k = new int[q];
       
        for (int i = 0; i < n; i++)
        {
            string[]u = Console.ReadLine().Split();
            d[i] = int.Parse(u[0]);
            p[i] = int.Parse(u[1]);
        }
        for (int j = 0; j < q; j++)
        {
            k[j]=int.Parse(Console.ReadLine());
        }
        for (int j = 0; j < q; j++)
        {
            int kDan = k[j];

            int zalihe = 0;
            int pojedeno = 0;
             
            int i = 0;
           for(int dan=1;dan<=kDan;dan++)
            {
                while(i<n && dan == d[i])
                {
                    zalihe += p[i];
                   
                    i++;

                }
                if(zalihe>0)
                {
                    zalihe--;
                    pojedeno++;
                }
            }

            Console.WriteLine(pojedeno);
        }
        
        











    }
}