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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] c = Console.ReadLine().Split(' ');
            string cs;
            long n = Convert.ToInt64(c[0]), q = Convert.ToInt64(c[1]), z, p;
            long[,] a = new long[n, 2];
            long[] rez = new long[q];
            bool k = true;
            for (int i = 0; i < n; i++)
            {
                c = Console.ReadLine().Split(' ');
                a[i, 0] = Convert.ToInt64(c[0]);
                a[i, 1] = Convert.ToInt64(c[1]);
            }
            for (int i = 0; i < q; i++)
            {
                cs = Console.ReadLine();
                z = 0;
                p = 0;
                k = true;
                for (int j = 0; j < n; j++)
                {
                    z += a[j, 1];
                    if (Convert.ToInt64(cs) < a[j, 0])
                        break;
                    if (z + a[j, 0] < Convert.ToInt64(cs))
                    {
                        p += z;
                        z = 0;
                        k = true;
                    }
                    else
                    {
                        p += (Convert.ToInt64(cs) - a[j, 0]);
                        z -= (Convert.ToInt64(cs) - a[j, 0]);
                        if (k)
                        {
                            p += 1;
                            z -= 1;
                        }
                        k = false;
                    }
                }
                rez[i] = p;
            }
            foreach (long x in rez)
                Console.WriteLine(x);
        }
    }
}