using System;

class Program
{
    static void Main()
    {
        string[] s1 = Console.ReadLine().Split();
        long n = long.Parse(s1[0]);
        long q = long.Parse(s1[1]);
        long[] d = new long[n];
        long[] p = new long[n];
        for (int i = 0; i < n; i++)
        {
            string[] s2 = Console.ReadLine().Split();
            d[i] = long.Parse(s2[0]);
            p[i] = long.Parse(s2[1]);
        }
        int[] k = new int[q];
        for (int j = 0; j < q; j++)
        {
            k[j] = int.Parse(Console.ReadLine());
        }

        for (int j = 0; j < q; j++)
        {
            long br = 0;
            long k2 = k[j];
            for (int i = 0; i < n && d[i] <= k2; i++)
            {
                br += p[i];
            }
            if (br > k[j])
                Console.WriteLine(br - k[j]);
        }
    }
}