#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct m
{
    uint_fast64_t d;
    uint_fast32_t p;
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    uint_fast16_t n,q;
    cin>>n>>q;
    m dan[n];
    uint_fast64_t k[q];
    uint_fast32_t plazma=0;
    uint_fast32_t pojela=0;
    uint_fast32_t j = 0;
    uint_fast32_t z = 0;
    uint_fast32_t c = 0;
    for(int i = 0; i<n;i++)
        cin>>dan[i].d>>dan[i].p;
    for(int i = 0;i<q;i++)
        cin>>k[i];
    while(c<q)
    {
        if(j<n)
        {
            if(z==dan[j].d)
            {
                plazma+=dan[j].p;
                j++;
            }
        }
        if(plazma>0)
        {
            pojela++;
            plazma--;
        }
        if(k[c]==z)
        {
            cout<<pojela<<endl;
            c++;
        }
        z++;
    }

}