using System;

namespace Krug1Zadatak2
{
    struct Plazma
    {
        public ulong d;
        public int p;
        public Plazma(ulong d, int p)
        {
            this.d = d;
            this.p = p;
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] input;
            input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int q = int.Parse(input[1]);
            Plazma[] plazmas = new Plazma[n];
            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                plazmas[i] = new Plazma(ulong.Parse(input[0]), int.Parse(input[1]));
            }
            int l, s;
            ulong[] k = new ulong[q];
            for (int i = 0; i < q; i++)
            {
                k[i] = ulong.Parse(Console.ReadLine());
            }
            for (int i = 0; i < q; i++)
            {
                s = 0;
                l = 0;
                for (ulong j = 0; j < k[i]; j++)
                {
                    for (int m = 0; m < plazmas.Length; m++)
                    {
                        if (plazmas[m].d == j + 1)
                        {
                            l += plazmas[m].p;
                            break;
                        }
                    }
                    if (l > 0)
                    {
                        l--;
                        s++;
                    }
                }
                Console.WriteLine(s);
            }
            Console.ReadKey();
        }
    }
}