using System;

class Pecina
{
    static void Main()
    {
        var ulaz = Console.ReadLine().Split();
        long n = long.Parse(ulaz[0]);
        long q = long.Parse(ulaz[1]);

        long[] d = new long[n];
        long[] p = new long[n];

        for (long i = 0; i < n; i++)
        {
            var ulaz2 = Console.ReadLine().Split();
            d[i] = long.Parse(ulaz2[0]);
            p[i] = long.Parse(ulaz2[1]);  
        }

        for (long l = 0; l < q; l++)
        {
            long j = long.Parse(Console.ReadLine());
            long m = 0;

            for (long v = 0; v < n; v++)
            {
                if (d[v]<j)
                {
                    m += p[v];
                }
            }
            Console.WriteLine(m);
        }
    }
}