#include <bits/stdc++.h>
using namespace std;

void print_int_matrix(vector<long long unsigned int> v)
{
    for (long long unsigned int i : v)
    {
        cout << i << " ";
    }
    cout << "\n\n";
}

int main()
{
    long long unsigned int n; // how many times dad bought plazma
    long long unsigned int q; // how many questions
    cin >> n >> q;
    vector<long long unsigned int> d(n);         // days
    vector<long long unsigned int> p(n);         // number of plazmas bought
    vector<long long unsigned int> questions(q); // the days we're questioning
    long long unsigned int total_total_plazmas = 0;
    for (long long unsigned int i = 0; i < n; i++)
    {
        cin >> d[i];
        cin >> p[i];
        total_total_plazmas += p[i];
    }
    for (long long unsigned int i = 0; i < q; i++)
    {
        cin >> questions[i];
    }

    for (long long unsigned int i = 0; i < q; i++)
    {
        long long unsigned int total_plazmas = 0;
        if (questions[i] > total_total_plazmas)
        {
            cout << total_total_plazmas << "\n";
            continue;
        }
        vector<long long unsigned int> days(questions[i] + 1);

        for (long long unsigned int j = 1; j <= questions[i]; j++)
        {
            days[j] = j;
        }

        vector<long long unsigned int> plazmas_in_stock(questions[i] + 1);

        long long unsigned int x = 0;

        for (long long unsigned int j = 1; j <= questions[i]; j++)
        {

            if (j == d[x])
            {
                plazmas_in_stock[j] += p[x] - 1;
                total_plazmas += p[x];
                x++;
            }

            else if (plazmas_in_stock[j - 1] > 0)
                plazmas_in_stock[j] = plazmas_in_stock[j - 1] - 1;
        }
        cout << total_plazmas - plazmas_in_stock[questions[i]] << "\n";

        days.clear();
        plazmas_in_stock.clear();
    }
}