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

namespace ConsoleApp4
{
    internal class Program
    {
        static void M(int[] b, int[] a, int[] c)
        {
            int i = 0;
            for (int j = 0; j < b.Length; j++)
            {
                if (i < c[j]) i = c[j];
                while (b[j] > 0)
                {
                    a[i] = 1;
                    i++;
                    b[j]--;
                }
            }
        }
        static void Main(string[] args)
        {
            string[] nq = Console.ReadLine().Split();
            int n = Convert.ToInt32(nq[0]);
            int q = Convert.ToInt32(nq[1]);
            int[] a = new int[n];
            int[] b = new int[n];
            int zb = 0;
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                a[i] = Convert.ToInt32(s[0]);
                b[i] = Convert.ToInt32(s[1]);
                zb += b[i];
            }
            int[] c = new int[q];
            for (int i = 0; i < q; i++)
            {
                c[i] = Convert.ToInt32(Console.ReadLine());
            }
            int k = 0;
            int[] z = new int[q];
            int i1 = 0;
            for (int i = 0; i < q; i++)
            {
                int[] tem = new int[zb + 1000];
                M(b, tem, a);
                for (int j = 0; j < c[i1] + 1; j++)
                {
                    z[i] += tem[j];
                }
                Console.WriteLine(z[i]);
            }
        }
    }
}