using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] NQ = Console.ReadLine().Split(" ");
        long N = long.Parse(NQ[0]);
        long Q = long.Parse(NQ[1]);
        long[] nizd = new long[N];
        long[] nizp = new long[N];
        long[] nizk = new long[Q];
        for (int i = 0; i < N; i++)
        {
            string[] dp = Console.ReadLine().Split(" ");
            nizd[i] = long.Parse(dp[0]);
            nizp[i] = long.Parse(dp[1]);
        }
        for(long i = 0; i < Q;i++)
        {
            nizk[i] = long.Parse(Console.ReadLine());
        }
        

        long br = 0;
        long zaliha = 0;
        long br2 = 0;
        long pdani = 0;
        for(long j = 1; j <= nizk.Last(); j++)
        {
            if (nizd[br] == j)
            {
                zaliha += nizp[br];
                if(br < N-1)
                {
                    br++;
                }
            }
            if(zaliha > 0)
            {
                zaliha--;
                pdani++;
            }
            if(j == nizk[br2])
            {
                Console.WriteLine(pdani);
                br2++;
            }
        }

    }
}