using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plazma2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] ulaz = Console.ReadLine().Split();
            int N = int.Parse(ulaz[0]);
            int Q = int.Parse(ulaz[1]);
            long[] K = new long[N];
            long[] D = new long[N];
            long[] P = new long[Q];
            for(int i = 0; i < N; i++)
            {
                ulaz = Console.ReadLine().Split();
                K[i] = long.Parse(ulaz[0]);
                D[i] = long.Parse(ulaz[1]);

            }
            for(int i = 0;i < Q; i++)
            {
                P[i] = long.Parse(Console.ReadLine());
            }
            long[] res = new long[Q];
            for(int i = 0; i < Q; i++)
            {
                long trenutandan = P[i];
                long Ukupnoplazme = 0;
                
                for(int j = 0; j < N; j++)
                {
                    if(K[j] <= trenutandan)
                    {
                        long mogucidani = Math.Max(0,trenutandan-K[j]+1);
                        long mogucaplazma = Math.Min(D[j],mogucidani);
                        Ukupnoplazme += mogucaplazma;
                    }
                }
                long resenje = Math.Min(Ukupnoplazme, trenutandan);
                res[i] = resenje;
            }
            for(int i = 0;i<Q;i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}