using System;

class Program
{
    static void Main()
    {
        string[] pl = Console.ReadLine().Split(' ');
        int N = int.Parse(pl[0]);
        int Q = int.Parse(pl[1]);
        string[] linija = new string[2];
        int d, p, k, l, rez, f;
        int[] dani = new int[N];
        int[] plazma = new int[N];
        int[] pitanja = new int[Q];
        l = 0;
        rez = 0;
        f = 0;
        
        for (int i = 0; i < N; i++)
        {
            linija = Console.ReadLine().Split(' ');
            d = int.Parse(linija[0]);
            p = int.Parse(linija[1]);
            dani[i] = d;
            plazma[i] = p;
        }
        
        for (int i = 0; i < Q; i++)
        { 
            k = int.Parse(Console.ReadLine());
            pitanja[i] = k;
        }
        
        for (int y = 0; y < Q; y++)
        {
            for (int i = 1; i <= pitanja[y]; i++)
            {
                if (i == dani[f])
                {
                    l = l + plazma[f];
                    f++;
                    if (f > N - 1)
                        f = 0;
                }
                if (l > 0)
                {
                    rez++;
                    l = l - 1;
                }
            }
            Console.WriteLine(rez);
        }
    }
}