using System;

class aaaaaa
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        long n = long.Parse(s[0]);
        long q = long.Parse(s[1]);
        
        long[] a = new long[n];
        long[] b = new long[n];
        
        for (long i=0; i<n; i++)
        {
            string[] s2 = Console.ReadLine().Split();
            a[i] = long.Parse(s2[0]);
            b[i] = long.Parse(s2[1]);
        }
        
        long[] rez = new long[q]; long w=0;
        while (w < q)
        {
            long r = 0, r2=0;
            long k = long.Parse(Console.ReadLine());

            for (long j = 0; j<n; j++)
            {
                if (a[j]<k) { r+=b[j]; r2+=a[j];}
            }
            
            rez[w] = r;
            if ((r-k)>0) rez[w] = r-k;
            else if ((k-r2)>0 && (k-r2)<r) rez[w] = k-r2+1;
            w++;
        }
        
        for (long i=0; i<q; i++)
        {
            Console.WriteLine(rez[i]);
        }
    }
}