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

namespace ConsoleApplication1
{
    class Program
    {
        static int BestMove(int currentMove, int[] d, int[] p, ref int totalP, int health, int N)
        {
            int damageD = d[currentMove] + totalP;
            int damageP = p[currentMove] + totalP;
            int totalP1 = totalP + p[currentMove];
            if (health - damageD <= 0 || health - damageP <= 0)
            {
                return health;
            }
            else if (currentMove + 1 < N && BestMove(currentMove + 1, d, p, ref totalP, health - damageD, N) < BestMove(currentMove + 1, d, p, ref totalP1, health - damageP, N))
            {
                totalP += p[currentMove];
                return damageP;
            }
            return damageD;
        }
        static void Main(string[] args)
        {
            string[] NQ = Console.ReadLine().Split();
            int N = int.Parse(NQ[0]);
            int Q = int.Parse(NQ[1]);
            int[] D = new int[N];
            int[] P = new int[N];
            int[] answers = new int[Q];
            for (int i = 0; i < N; i++)
            {
                string[] DP = Console.ReadLine().Split();
                D[i] = int.Parse(DP[0]);
                P[i] = int.Parse(DP[1]);
            }
            for (int i = 0; i < Q; i++)
            {
                int H = int.Parse(Console.ReadLine());
                int totalP = 0;
                int totalMoves = 0;
                for (int j = 0; j < N; j++)
                {
                    H -= BestMove(j, D, P, ref totalP, H, N);
                    //maxDamage += BestMove(j, D, P, ref totalP, H);
                    totalMoves++;
                    if (H <= 0)
                    {
                        answers[i] = totalMoves;
                        j = N;
                    }

                }
                if (H > 0)
                {
                    answers[i] = -1;
                }
            }

            for (int i = 0; i < Q; i++)
            {
                Console.WriteLine(answers[i]);
            }
            //Console.WriteLine(maxDamage);

        }
    }
}