using System;
 internal class Program
 {
     static void Main(string[] args)
     {
         string[] unos = Console.ReadLine().Split(" ");
         int N = int.Parse(unos[0]);
         int Q = int.Parse(unos[1]);

         int[] di = new int[N];
         long[] pi = new long[N];
         for (int i = 0; i < N; i++)
         {
             string[] dp = Console.ReadLine().Split(" ");
             di[i] = int.Parse(dp[0]);
             pi[i] = long.Parse(dp[1]);               
         }

         long[] pitanja = new long[Q];
         for (int j = 0; j < Q; j++)
         {
             string ulazp = Console.ReadLine();
             pitanja[j] = long.Parse(ulazp);
         }

         long stek = 0;
         int pojela = 0;
         for (int i = 0; i < Q; i++) //broj pitanja
         {
             pojela = 0;
             long[] dani = new long[pitanja[i]];
             for (int j = 1; j <= pitanja[i]; j++)
             {
                 dani[i] = j;
             }
             for (int k = 1; k <= dani.Length; k++)
             {
                 for (int kk = 0; kk < di.Length; kk++)
                 {
                     if (di[kk] == k)
                     {
                         stek = stek + pi[kk];
                         pojela++;
                         stek--;
                         kk++;
                         break;
                     }
                     else
                     {
                         if (stek > 0)
                         {
                             stek--;
                             pojela++;
                             kk++;
                         }
                     }
                 }
             }
             Console.WriteLine(pojela);
         }
     }
 }