#include <iostream>
using namespace std;
void f1(int n,int i, unsigned long long p[],unsigned long long d[],unsigned long long q[]){
	unsigned long long sum=0;
	for(int j=0;j<n;j++){
		if(p[j]<q[i]-d[j]){
			sum += p[j];
		}else{
			if(q[i]-d[j] > 0){
			sum += q[i]-d[j]+1;}
		}
	}
	if(sum > q[i]){
		cout<<q[i];
	}else if(sum <= 0){
		cout<<0;
	}else{
		cout<<sum;
	}
}

int main(){
	int n,Q;
	cin>>n>>Q;
	unsigned long long d[n];
	unsigned long long p[n];
	for(int i=0;i<n;i++){
		cin>>d[i]>>p[i];
	}
	unsigned long long q[Q];
	for(int i=0;i<Q;i++){
		cin>>q[i];
	}
	for(int i=0;i<Q;i++){
		f1(n,i,p,d,q);
	}
}