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

namespace TakmicenjePlazma2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split();
            long n = int.Parse(s1[0]);
            long nq = int.Parse(s1[1]);
            long[] d = new long[n];
            long[] p = new long[n];
            long[] q = new long[nq];
            long s = 0;
            for (long i = 0; i < n; i++)
            {
                string[] sw = Console.ReadLine().Split();
                d[i] = long.Parse(sw[0]);
                p[i] = long.Parse(sw[1]);
            }
            for (long i = 0; i < nq; i++)
            {
                q[i] = long.Parse(Console.ReadLine());
            }
            for (long i = 0; i < nq; i++)
            {
                long k = q[i];
                for (long j = 0; j < n; j++)
                {
                    if (d[0] > k)
                    {
                        Console.WriteLine("0");
                        break;
                    }
                    if (d[j] <= k)
                    {
                        if (s + p[j] + (d[j] - 1) < k)
                        {
                            s += p[j];
                        }
                        else
                        {
                            s += k - (d[j] - 1);
                            Console.WriteLine(s);
                            s = 0;
                            break;
                        }
                        if(j==n-1)
                        {
                            Console.WriteLine(s);
                            s = 0;
                        }
                    }
                }
            }                      
            Console.Read();
        }
    }
}