using System;
namespace Plazma 
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input.Split()[0]);
            int Q = int.Parse(input.Split()[1]);
            
            long[] d = new long[N];
            long[] p = new long[N];
            long[] q = new long[Q];
            long[] outputs = new long[Q];
            for(int i = 0; i < N; i++)
            {
                input = Console.ReadLine();
                d[i] = long.Parse(input.Split()[0]);
                p[i] = long.Parse(input.Split()[1]);
            }

            for(int i = 0;i < Q; i++)
            {
                q[i] = long.Parse(Console.ReadLine());
            }

            for(int i = 0; i<Q; i++) 
            {
                long brojdana = q[i];
                long njam = 0;
                long supply = 0;

                for(int j = 0; j <= brojdana; j++)
                {
                    bool check = true;
                    bool found = false;
                    long di = 0;
                    while(check && di < d.Length)
                    {
                        if (d[di] == j) 
                        {
                            check = false; found = true;
                            supply += p[di];
                        }
                        else if (d[di] > j) 
                        {
                            check = false;
                        }
                        di++;
                    }
                    if(supply > 0) { supply--;njam++; }
                }

                outputs[i] = njam;
            }
            foreach(int i in outputs)
            {
                Console.WriteLine(i);
            }
        }
    }
}