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

namespace plazma
{
    internal class Program
    {
        static void pp(long[] dk, long[] bp, long[] dp)
        {
            long i = 0;
            for (long j = 0; j < dk.Length; j++)
            {
                if (i < dp[j])
                    i = dp[j];

                while (dk[j] > 0)
                {
                    bp[i] = 1;
                    i++;
                    dk[j]--;
                }
            }
        }
        static void Main(string[] args)
        {
            string[] nq = Console.ReadLine().Split();
            long n = long.Parse(nq[0]);
            long q = long.Parse(nq[1]);
            long[] bp = new long[n]; 
            long[] dk = new long[n]; 
            long up = 0;
            for (long i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                bp[i] = long.Parse(s[0]); 
                dk[i] = long.Parse(s[1]); 
                up += bp[i]; 
            }
            long[] dp = new long[q];
            for (long i = 0; i < q; i++)
            {
                dp[i] = long.Parse(Console.ReadLine()); 
            }
            long[] rez = new long[q]; 
            for (long i = 0; i < q; i++)
            {
                long[] privremena = new long[up + 1000]; 
                pp(dk, privremena, bp);
                for (long j = 0; j < dp[i] + 1; j++)
                {
                    rez[i] += privremena[j];
                }
                Console.WriteLine(rez[i]); 
            }
        }
        }
    }