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

namespace ConsoleApp1
{
    internal class Program
    { 
        static long prvi_manji(long[] dani,long dan)
        {
            long l = 0, d = dani.Length - 1;
            while (l <= d)
            {
                long s = (l + d) / 2;
                if (dani[s] > dan)
                    d = s - 1;
                else
                    l = s + 1;
            }
            return l-1;
        }
        static long pojedeno(long[] dani, long[] ukupan_keks,long dan)
        {
            long d = prvi_manji(dani, dan);
            if (d < 0)
                return 0;
            if (ukupan_keks[d] == 0)
                return 0;
            if (dani[0] == dan)
                return 1;
            if (dani[d] == dan) 
                return pojedeno(dani, ukupan_keks, dan - 1) + 1;
            if (dan - dani[d] >= ukupan_keks[d] - 1)
                return ukupan_keks[d];
            else
                return pojedeno(dani, ukupan_keks, dan - 1) + 1;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int br_dana = int.Parse(s[0]);
            int br_upita = int.Parse(s[1]);
            long[] dani = new long[br_dana];
            long[] keks = new long[br_dana];
            for(int i = 0;i<br_dana; i++)
            {
                s = Console.ReadLine().Split();
                dani[i] = long.Parse(s[0]);
                keks[i] = long.Parse(s[1]);
            }
            long[] ukupan_keks = new long[br_dana];
            ukupan_keks[0] = keks[0];
            for (int i = 1; i < br_dana; i++)
                ukupan_keks[i] = ukupan_keks[i - 1] + keks[i];
            for (int i = 0; i < br_upita; i++) 
            {
                long dan = long.Parse(Console.ReadLine());
                Console.WriteLine(pojedeno(dani, ukupan_keks, dan));
            }
        }
    }
}