using System;



internal class Program
{
    static void Main(string[] args)
    {
        
        string s = Console.ReadLine();
        s = s + ' ';
        int m = 0;
        string s1 = "";
        while (!(s[m].Equals(' ')))
        {
            s1 = s1 + s[m];
            m++;
        }
        m++;
        int n = Convert.ToInt32(s1);
        long[] d = new long[n+1];
        int[] p = new int[n+1];
        s1 = "";
        while (!(s[m].Equals(' ')))
        {
            s1 = s1 + s[m];
            m++;
        }
        int q = Convert.ToInt32(s1);
        long[] k = new long[q+1];
        long[] r = new long[q + 1];
        for (int i = 1; i <= n; i++)
        {
            s = Console.ReadLine();
            s = s + ' ';
            m = 0;
            s1 = "";
            while (!(s[m].Equals(' ')))
            {
                s1 = s1 + s[m];
                m++;
            }
            m++;
            d[i] = Convert.ToInt64(s1);
            s1 = "";
            while (!(s[m].Equals(' ')))
            {
                s1 = s1 + s[m];
                m++;
            }
            p[i] = Convert.ToInt32(s1);
        }
        k[0] = 0;

        for (int i = 1; i <= q; i++)
        {
            k[i] = Convert.ToInt64(Console.ReadLine());
            int u = 1;
            int t = 0;
            for (long j = k[i - 1] + 1; j <= k[i]; j++)
            {
                if (u <= n )
                {
                    if (d[u] == j)
                    {
                        t = t + p[u];
                        u++;
                    }
                }
                if (t > 0)
                {
                    r[i]++;
                    t--;
                }
                
            }
            Console.WriteLine(r[i]);
            
        }
        Console.ReadLine();
    }
}