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

namespace takm2
{
    internal class Program
    {
        static long[] CheckQuestion(long[] questions, long[] days, long[] plazmas, int n, int q)
        {
            long currentDay = 0;
            long startingPoint = days[currentDay];
            long totalPlazmas = 0;
            long availablePlazmas = 0;
            long[] answers = new long[q];
            for(int i = 0; i < q; i++)
            {
                for(long j = startingPoint; j <= questions[i]; j++)
                {
                    for(long k = currentDay; k < n; k++)
                    {
                        if (j == days[k])
                        {
                            availablePlazmas += plazmas[k];
                            currentDay = k;
                            break;
                        }
                    }
                    if (availablePlazmas > 0)
                    {
                        totalPlazmas++;
                        availablePlazmas--;
                    }
                    else if (availablePlazmas == 0)
                    {
                        if (currentDay < n - 1)
                        {
                            j = days[currentDay + 1] - 1;
                            startingPoint = j;
                            currentDay++;
                        }
                        else if (currentDay > n - 1)
                        {
                            j = questions[i] + 1;
                        }
                    }
                    if (currentDay > n - 1 && questions[i] > availablePlazmas)
                    {
                        totalPlazmas += availablePlazmas;
                        availablePlazmas = 0;
                        j = questions[i] + 1;
                    }
                    startingPoint = j + 1;
                }
                answers[i] = totalPlazmas;
            }
            return answers;
        }
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split();

            int n = int.Parse(input1[0]);
            int q = int.Parse(input1[1]);

            long[] d = new long[n];
            long[] p = new long[n];
            long[] k = new long[q];

            for(int i = 0; i < n; i++)
            {
                string[] inputdp = Console.ReadLine().Split();
                d[i] = Convert.ToInt64(inputdp[0]);
                p[i] = Convert.ToInt64(inputdp[1]);
            }

            for(int i = 0; i < q ; i++) 
            {
                k[i] = Convert.ToInt64(Console.ReadLine());
            }
            long[] answers = CheckQuestion(k, d, p, n, q);
            for (int i = 0; i < q; i++)
                Console.WriteLine(answers[i]);
        }
    }
}