import java.util.Scanner;
public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        
        int N = in.nextInt();
        int Q = in.nextInt();
        
        
        int[] dani = new int[N];
        int[] plazma = new int[N];
        
        
        for (int i = 0; i < N; i++) {
            dani[i] = in.nextInt();
            plazma[i] = in.nextInt();
        }
        
        
        int[] pitanja = new int[Q];
        for (int i = 0; i < Q; i++) {
            pitanja[i] = in.nextInt();
        }
        
        
        int[] totalPlasma = new int[N];
        totalPlasma[0] = plazma[0];
        
        
        for (int i = 1; i < N; i++) {
            totalPlasma[i] = totalPlasma[i - 1] + plazma[i];
        }
        
        
        for (int pitanje : pitanja) {
            
            int result = 0;
            for (int i = 0; i < N; i++) {
                if (dani[i] <= pitanje) {
                    result = totalPlasma[i]; 
                } else {
                    break;
                }
            }
            System.out.println(result);
        }
        
        in.close();
    }