#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
    int p, q, i, j;
    long long k, pom1, pom2;
    cin >> p >> q;
    vector<pair<int, int>> x(p);
    vector<int> y(q);
    for (i = 0; i < p; i++)
    {
        cin >> x[i].first >> x[i].second;
    }
    for (i = 0; i < q; i++)
    {
        cin >> y[i];
    }
    for (i = 0; i < q; i++)
    {
        pom1 = 0;
        pom2 = 0;
        k = 0;
        for (j = 0; j < p; j++)
        {
            if (y[i] > x[j].first)
            {
                pom1 = x[j].second;
                pom2 = y[i] - x[j].first+1;
                k += min(pom1, pom2);
            }  
        }
        if (k != 0)
            cout << k << endl;
        else if(x[0].first > y[i]) {
            cout << 0 << endl;
        }
        else
        {
            pom1 = y[i] - x[0].first+1;
            k = min(pom1, (long long)y[i]);
            cout << k << endl;
        }
    }
}