using System;

class Pecina
{
    static void Main()
    {
        var ulaz = Console.ReadLine().Split();
        long n = long.Parse(ulaz[0]);
        long q = long.Parse(ulaz[1]);

        long[] d = new long[n];
        long[] p = new long[n];

        for (long i = 0; i < n; i++)
        {
            var ulaz2 = Console.ReadLine().Split();
            d[i] = long.Parse(ulaz2[0]);
            p[i] = long.Parse(ulaz2[1]);  
        }

        for (long l = 0; l < q; l++)
        {
            long j = long.Parse(Console.ReadLine());
            long m = 0;
            long k = 0;
            long a = 0;
            long f = d[n - 1];
            for (long v = 1; v < j; v++)
            {
                 if (p[a]!=0 && d[k]!=j+1)
                {
                    m++;
                    p[a]--;
                    d[k]++;
                }
                else
                {
                    a++;
                    k = 0;
                }
            }
            Console.WriteLine(m);
        }
    }
}