import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner upis = new Scanner(System.in);

        
        int N = upis.nextInt();
        int Q = upis.nextInt();

       
        if (N < 1 || N >= 300000 || Q < 1 || Q >= 300000) {
            System.out.println("Greska N ili Q");
            return;
        }
        
        int[] dan = new int[N];
        int[] pakovanja = new int[N];
        for (int i = 0; i < N; i++) {
            dan[i] = upis.nextInt();
            pakovanja[i] = upis.nextInt();

            if (dan[i] < 1 || dan[i] >= Math.pow(10, 18) || pakovanja[i] < 1 || pakovanja[i] >= Math.pow(10, 9)) {
                System.out.println("Greska dan ili pakovanja");
                return;
            }
        }

  
        for (int i = 0; i < Q; i++) {
            int k = upis.nextInt();
            long pojedena = 0;
            long preostali = k;
            for (int j = 0; j < N && preostali > 0; j++) {
                
                long slobodni = (j == 0 ? dan[j] : dan[j] - dan[j - 1]);
                long dostupnap = Math.min(preostali, Math.min(slobodni, pakovanja[j]));
                pojedena += dostupnap;
                preostali -= dostupnap; 
            }
            
            System.out.println(pojedena);
        }

        upis.close();
    }
}