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

namespace Plazma___Petlja_2024
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 0, Q = 0;

            string unos = Console.ReadLine();
            for (int i = 0; i < unos.Length; i++)
                if (unos[i] == ' ')
                {
                    N = Convert.ToInt32(unos.Substring(0, i));
                    Q = Convert.ToInt32(unos.Substring(i + 1, unos.Length - 1 - i));
                }

            int[] d = new int[N], p = new int[N], k = new int[Q], l = new int[Q];

            for (int i = 0; i < N; i++)
            {
                unos = Console.ReadLine();
                for (int j = 0; j < unos.Length; j++)
                    if (unos[j] == ' ')
                    {
                        d[i] = Convert.ToInt32(unos.Substring(0, j));
                        p[i] = Convert.ToInt32(unos.Substring(j + 1, unos.Length - 1 - j));
                    }
            }

            int br1 = 0, br2 = 0;

            for (int i = 0; i < Q; i++)
            {
                unos = Console.ReadLine();
                k[i] = Convert.ToInt32(unos);
                for (int j = 1; j <= k[i]; j++)
                {
                    if (j == d[br1])
                    {
                        br2 += p[br1];
                        if (br1 < d.Length - 1) br1++;
                    }
                    if (br2 > 0) { l[i]++; br2--; }
                }
            }

            foreach (int i in l)
                Console.WriteLine(i);

            Console.ReadLine();
        }
    }
}