using System;
internal class Program
{
    static void Main(string[] args)
    {
        string[] u1 = Console.ReadLine().Split(' ');
        int n = Convert.ToInt32(u1[0]); int q = Convert.ToInt32(u1[1]);
        long[] d=new long[n];
        int[] p=new int[n];
        long[] k=new long[q];
        for (int i = 0; i < n; i++)
        {
            string[] u2 = Console.ReadLine().Split(' ');
            d[i] = long.Parse(u2[0]); p[i] = int.Parse(u2[1]);
        }
        for (int j = 0; j < q; j++)
        {
            k[j] = long.Parse(Console.ReadLine());
        }
        for(int j=0; j < q; j++)
        {
            long[] niz = new long[k[j]];
            long pojelabr = 0;
            for(int i = 0; i < n; i++)
            {                
                for(int i2 = 0;i2 < k[j]; i2++)
                {
                    if (i2 + 1 == d[i])
                    {
                        niz[i2] = p[i];
                        
                    }                       
                    
                }
            }
            for(int i = 0; i < k[j]; i++)
            {
                
                if (niz[i] != 0)
                {
                    if (i == k[j] - 1)
                    {
                        pojelabr++;
                    }
                    else {
                        niz[i + 1]=niz[i]-1;
                        pojelabr++;
                    }
                    
                }

            }
            Console.WriteLine(pojelabr);
        }
    }
}