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]);
        int[] d = new int[n];
        int[] p = new int[n];
        int[] k = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split();
            d[i] = int.Parse(input[0]);
            p[i] = int.Parse(input[1]);
        }
        for (int j = 0; j < q; j++)
            k[j] = int.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();
    }
}