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

namespace Plazma
{
    internal class Program
    {
        static long pretRes = 0;
        static long pretZalihe = 0;
        static int pretNi = 0;
        static long pretI = 1;

        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];
            long[] p = new long[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] = long.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, long[] p, long[] d)
        {
            long res = pretRes;
            long zalihe = pretZalihe;
            int Ni = pretNi;

            for (long i = pretI; 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;
                else if (d[Ni] <= k)
                {
                    i = d[Ni] - 1;
                }
                else break;
            }
            pretRes = res;
            pretZalihe = zalihe;
            pretNi = Ni;
            pretI = k+1;

            return res;
        } 
    }
}