#include <iostream>
#include <bits/stdc++.h>

using namespace std;
struct plazma
{
    int dan;
    int kolicina;
};
int provera(plazma a[], int n, int q)
{
    int k = 0;
    int zaliha = 0;
    for(int dan = 1; dan <= q; dan++)
    {
        for(int i = 0; i < n; i++)
        {
            if(dan == a[i].dan){
                zaliha = zaliha + a[i].kolicina;
                break;
            }
        }
        if(zaliha != 0){
            zaliha--;
            k++;
        }
    }
    return k;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, q;
    cin >> n >> q;
    plazma a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].dan >> a[i].kolicina;
    }
    int pitanje[q];
    for(int i = 0; i < q; i++)
    {
        cin >> pitanje[i];
    }
    for(int i = 0; i < q; i++)
    {
        cout << provera(a,n,pitanje[i]) << endl;
    }
    return 0;
}