#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,q,brpak,pojela,k;
    cin>>n>>q;
    int d[n],p[n];
    for(int i=1;i<=n;i++)
    {
        cin>>d[i]>>p[i];
    }
    for(int j=1;j<=q;j++)
    {
        cin>>k;
        int br=1;
        pojela=0,brpak=0;
        for(int i=1;i<=k;i++)
        {

            if(brpak>0&&d[br]!=i)
            {
                brpak--;
                pojela++;
            }
            if(d[br]==i)
            {
                brpak+=p[br];
                br++;
                brpak--;
                pojela++;
            }
        }
        cout<<pojela<<endl;
    }

    return 0;
}