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

namespace zad_2_SPREMAN
{
    internal class Program
    {
        static void Metoda(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[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int q = int.Parse(s[1]);
            int[] d = new int[n];
            int[] p = new int[n];
            int zb = 0;
            for (int i = 0; i < n; i++)
            {
                string[] s1 = Console.ReadLine().Split();
                d[i] = int.Parse(s1[0]);
                p[i] = int.Parse(s1[1]);
                zb += p[i];
            }
            int[] c = new int[q];
            for (int i = 0; i < q; i++)
            {
                c[i] = int.Parse(Console.ReadLine());
            }
            int[] z = new int[q];
            int i1 = 0;
            for (int i = 0; i < q; i++)
            {
                int[] tem = new int[zb + 1000];
                Metoda(p, tem, d);
                for (int j = 0; j < c[i1] + 1; j++)
                {
                    z[i] += tem[j];
                }
                Console.WriteLine(z[i]);
            }

        }
    }
}