using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

class Program
{





    static void Main()
    {
        string[] ulaz = Console.ReadLine().Split();
        int n = int.Parse(ulaz[0]);
        int q = int.Parse(ulaz[1]);

        long[] d = new long[n];
        long[] p = new long[n];
        long[] k = new long[q];

        for (int i = 0; i < n; i++)
        {
            string[] u = Console.ReadLine().Split();
            d[i] = int.Parse(u[0]);
            p[i] = int.Parse(u[1]);
        }
        for (int j = 0; j < q; j++)
        {
            k[j] = long.Parse(Console.ReadLine());
        }
        for (int j = 0; j < q; j++)
        {
            long kDan = k[j];

            long zalihe = 0;
            long pojedeno = 0;

            int i = 0;
            for (int dan = 1; dan <= kDan; dan++)
            {
                while (i < n && dan == d[i])
                {
                    zalihe += p[i];

                    i++;

                }
                if (zalihe > 0)
                {
                    zalihe--;
                    pojedeno++;
                }
            }

            Console.WriteLine(pojedeno);
        }













    }
}