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

namespace Plazma
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] line1 = Console.ReadLine().Split(' ');

            int N = int.Parse(line1[0]);
            int Q = int.Parse(line1[1]);

            long[] d = new long[N];
            int[] p = new int[N];
            

            long[] k = new long[Q];

            for(int i= 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                d[i] = long.Parse(s[0]);
                p[i] = int.Parse(s[1]);
            }

            for(int i= 0; i < Q; i++)
            {
                k[i] = long.Parse(Console.ReadLine());
            }

            for(int i= 0;i<Q; i++)
            {
                Console.WriteLine(Odgovor(N, k[i], p, d));
            }
        }

        static long Odgovor(int N, long k, int[] p, long[] d)
        {
            long zalihe = 0;
            int Ni = 0;

            long res = 0;

            for (long i = 1; i <= k; i++)
            
            {
                if (Ni < N && d[Ni] <= i)
                {
                    zalihe += p[Ni];
                    Ni++;
                }
                if (zalihe > 0)
                {
                    if (zalihe > k-i+1)
                    {
                        res += k - i + 1;
                        zalihe -= k - i + 1;
                        i += k - i + 1;
                    }
                    else
                    {
                        i += zalihe - 1;
                        res += zalihe;
                        zalihe = 0;
                    }
                    
                }
                else if (Ni >= N) break;
            }
            return res;
        } 
    }
}