#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	int q;
	cin>>n>>q;
	int broj;
	unsigned long long dan;
	vector<int> pitanja(q,0);
	unsigned long long k=0;
	int proslibroj=0;
	vector<unsigned long long> brojplazme;
	while(n>0){
		cin>>dan;
		cin>>broj;
		for(int i=k; i<k+dan-1-proslibroj; i++){
			brojplazme.push_back(0);
		}
		k=k+dan-1;
		for(int i=k; i<k+broj; i++){
			brojplazme.push_back(1);
		}
		k=k+broj;
		proslibroj=broj;
		n--;
	}
	n=q;
	k=0;
	while(q>0){
		cin>>broj;
		for(unsigned long long i=0; i<broj; i++){
			pitanja[k]+=brojplazme[i];
		}
		k++;
		q--;
	}
	for(int i=0; i<n; i++){
		cout<<pitanja[i]<<endl;
	}
	return 0;
}