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

namespace ConsoleApplication1
{
    class Program
    {
        static int BestMove(int damage, int currentMove, int[] d, int[] p, int totalP)
        {
            int damageD = d[currentMove] + totalP; 
            int damageP = p[currentMove] + totalP;
            if (damageD > damageP)
            {
                return 0;
            }
            else if (damageD < damageP)
            {
                return 1;
            }
            else if (damageD == damageP)
            {
                return 1;
            }
            return 100;
        }
        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 damage = 0;
                int totalP = 0;
                int totalMoves = 0;

                for (int j = 0; j < N; j++)
                {
                    int move = BestMove(damage, j, D, P, totalP);
                    if (move == 0)
                    {
                        damage = D[j] + totalP;
                    }
                    else if (move == 1)
                    {
                        damage = P[j] + totalP;
                        totalP += P[j];
                    }
                    else if (move == 100)
                    {
                        Console.WriteLine("problem");
                    }
                    H -= damage;
                    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]);
            }

        }
    }
}