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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] abgdv = s.Split();
            int n = Convert.ToInt32(abgdv[0]);
            int q = Convert.ToInt32(abgdv[1]);
            long[] d = new long[n]; long[] db = new long[n];
            long[] p = new long[n]; long[] pb = new long[n];
            long[] k = new long[q];
            long h = 0;long reset = 0; long p1 = 0;
            for (int i = 0; i < n; i++)
            {
                string s1 = Console.ReadLine();
                string[] abccc = s1.Split();
                d[i] = Convert.ToInt64(abccc[0]);
                p[i] = Convert.ToInt64(abccc[1]);
                pb[i] = p[i];
                db[i] = d[i];
            }
            for (int i = 0; i < q; i++)
            {
                k[i] = Convert.ToInt64(Console.ReadLine());
            }
            for (int i = 0; i < q; i++)
            {
                
                long izlaz = 0;
                for (int j = 0; j < n; j++)
                {
                    p1 = p[j] + h;
                    reset = k[i];
                    while (k[i] >= d[j] && p1 != 0)
                    {
                        izlaz++;
                        p1--;
                        k[i]--;
                    }
                    h = p1;
                    k[i] = reset;
                    p1 = 0;
                }
                Console.WriteLine(izlaz);
                izlaz = 0;
                p1 = 0; h = 0;
            }
        }
    }
}