using System;
using System.Collections.Generic;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        string[] s1 = Console.ReadLine().Split();
        int n = int.Parse(s1[0]);
        int q = int.Parse(s1[1]);
        Dictionary<long, long> map = new Dictionary<long, long>();
        for (int i = 0; i < n; i++)
        {
            s1 = Console.ReadLine().Split();
            map.Add(int.Parse(s1[0]), long.Parse(s1[1]));
        }
        long[] b = new long[q];
        for (int i = 0; i < q; i++)
        {
            b[i] = long.Parse(Console.ReadLine());
        }

        long[] odgovor = new long[q];
        for (int i = 0; i < q; i++)
        {
            int k = 0;
            long brojPlazmeUKuci = 0;
            long pojedenaPlazma = 0;
            for (int j = 1; j <= b[i]; j++)
            {
                if (map.ContainsKey(j)) { brojPlazmeUKuci += map[j]; k++; }
                if (brojPlazmeUKuci != 0) {
                    brojPlazmeUKuci--;
                    pojedenaPlazma++;
                }
                if (map.Count == k) {
                    if (b[i] >= brojPlazmeUKuci)
                    {
                        pojedenaPlazma += brojPlazmeUKuci;
                      
                    }
                    else {
                        pojedenaPlazma += b[i];
                    }
                    break;
                }
            }
            odgovor[i] = pojedenaPlazma;

        }
        for (int i = 0; i < q; i++)
        {
            Console.WriteLine(odgovor[i]);
        }

    }
}