using System;
using System.Linq;
namespace drugi_zadatak
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ot_u_pr = h[0];
            long br_pita = h[1];
            long[] k_d_k = new long[ot_u_pr];
            long[] k_p_k = new long[ot_u_pr];
            for (int i = 0; i < ot_u_pr; ++i)
            {
                var g = Console.ReadLine().Split().Select(long.Parse).ToArray();
                k_d_k[i] = g[0];
                k_p_k[i] = g[1];
            }
            for (int i=0; i<ot_u_pr; ++i)
            {
                long k_je_po_je = long.Parse(Console.ReadLine());
                long k_p_je_po = 0;
                long os_p = 0;
                for (int u=0; u<ot_u_pr; ++u)
                {
                    if (k_d_k[u] > k_je_po_je) break;
                    os_p += k_p_k[u];
                    long k_d_je = Math.Min(k_je_po_je - k_d_k[u] + 1, os_p);
                    k_p_je_po += k_d_je;
                    os_p -= k_d_je;
                }
                Console.WriteLine(k_p_je_po);
            }
        }
    }
}