#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    vector<pair<long long, int>> p;
    vector<long long int> ans;
    cin >> N >> Q;
    for (int i = 0;i < N;i++) {
        pair<long long, int> temp;
        cin >> temp.first >> temp.second;
        p.push_back(temp);
    }
    long long prevk=0,k, daysLeft, plazma = 0, eaten = 0;
    int dayInd=0;
    for (int i = 0;i < Q;i++) {
        cin >> k;
        if (k < p[dayInd].first) {
            long long meal = min(k - prevk, plazma);
            eaten += meal;
            plazma -= meal;
            ans.push_back(eaten);
            prevk = k;
            continue;
        }
        daysLeft = k-p[dayInd].first+1;
        for (dayInd;dayInd < N;dayInd++) {
            plazma += p[dayInd].second;
            long long meal = (dayInd == N - 1)?min(plazma,daysLeft) : min(min(plazma, daysLeft), p[dayInd + 1].first - p[dayInd].first);
            eaten += meal;
            plazma -= meal;
            daysLeft -= (dayInd == N - 1) ? meal: min(p[dayInd + 1].first - p[dayInd].first,daysLeft);
            if (daysLeft == 0|| dayInd == N - 1) {
                ans.push_back(eaten);
                prevk = k;
                dayInd++;
                break;
            }
        }
    }
    for (const auto& i : ans) {
        cout << i << "\n";
    }
}