#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    
    vector<int> p(n);
    vector<long long> d(n);
    for(int i=0;i<n;i++){
        cin>>d[i]>>p[i];
    }
    for(int i=0;i<q;i++){
        long long x, sum=0;
        cin>>x;
        vector<long long> dani(x, 0);
        for(long long j=0;j<x;j++){
            if(j==0 || dani[j-1]==0){
                auto it = find(d.begin(), d.end(),j+1);
                if (it != d.end()) {
                    int index = it - d.begin();
                    dani[j]=p[index]-1;
                    sum++;
                }
                else{
                    dani[j]=0;
                }
        }
        else{
           auto it = find(d.begin(), d.end(),j+1);
                if (it != d.end()) {
                    int index = it - d.begin();
                    dani[j]=p[index]-1;
                    sum++;
                }
                else{
                    dani[j]=dani[j-1]-1;
                    sum++;
                } 
        }
    }
    cout<<sum<<endl;
    
}
}