using System;
using System.Runtime.ExceptionServices;

class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split();
        int n = int.Parse(str[0]);
        int q = int.Parse(str[1]);
        long[] d = new long[n];
        long[] p = new long[n];
        long[] k = new long[q];
        long[] r = new long[q];
        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split();
            d[i] = long.Parse(input[0]);
            p[i] = long.Parse(input[1]);
        }
        for (int j = 0; j < q; j++)
            k[j] = long.Parse(Console.ReadLine());
        for (int j = 0; j < q; j++)
            for (int i = 0; i < n; i++)
                if (k[j] >= d[i])
                {
                    if (k[j] - d[i] + 1 >= p[i])
                        r[j] += p[i];
                    else if (k[j] - d[i] + 1 < p[i])
                        r[j] += k[j] - d[i] + 1;
                }
        for (int j = 0; j < q; j++)
            Console.WriteLine(r[j]);
        Console.ReadLine();
    }
}