#include <iostream>
#include <cmath>
using namespace std;
long mini (long a, long b)
{
    if(a>b)
        return b;
    return a;
}
long plazma (long k,long d[],int p[], int n)
{
    long bp=0;
    for (int i = 0; i < n; i++)
    {
        if(k>=d[i])
            bp+=mini(k-d[i]+1,p[i]);
        else
            i=n;
    }
    return mini(bp,k);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, Q;
    cin >> N >> Q;
    int p[N];
    long d[N], k[Q];
    p[0]=0;
    for (int i = 0; i < N; i++)
        cin >> d[i] >> p[i];
    for (int i = 0; i < Q; i++)
    {
        cin >> k[i];
        k[i]=plazma(k[i],d,p,N);
    }
    for (int i = 0; i < Q; i++)
        cout << k[i] << endl;
}