#include <iostream>
#include <bits/stdc++.h>
#define endl '\n';
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> v;
typedef vector<long long> vll;
typedef vector<long long int> vlli;

void res() {
    int n,q;
    cin>>n>>q;
    v h,d(n),p(n);
    for(int i=0;i<n;++i) {
        cin>>d[i]>>p[i];
    }

    sort(d.begin(), d.end());
    sort(p.begin(), p.end());
    for(int i=0;i<q;++i) {
        int hl; cin>>hl;
        h.push_back(hl);
    }
    bool xn1n(false),xn2n(false);
    for(int ht=0;ht<q;++ht) {
        int x(0);
        bool otr(false), nu(false);
        int hn1=h[ht], hn2=h[ht];
        int xn1=0, xn2=0;
        for(int i=0;i<n;++i) {
            if(xn1>q) {
                xn1n=true;
                break;
            }
            if(hn1<=0) {
                break;
            }
            hn1-=d[i];
            xn1++;
        }
        int p0=0;
        for(int i=0;i<n;++i) {
            if(xn2>q) {
                xn2n=true;
                break;
            }
            if(hn1<=0) {
                break;
            }
            h[ht] -= p0;
            hn1-=p[i];
            p0+=p[i];
            xn2++;
        }
        if(xn1n && xn2n) {
            cout<<-1<<endl;
        }
        else if(xn2n) {
                xn1--;
            cout<<xn1<<endl;
        }
        else if(xn1n) {
            xn2--;
            cout<<xn2<<endl;
        }
        else {
            if(xn1==0) {
                xn2--;
                cout<<xn2<<endl;
            }
            else if(xn2==0) {
                xn1--;
                cout << xn1<<endl;
            }
            else {
                cout<<min(xn1,xn2)-1<<endl;
            }
        }
        //cout<<endl;
        //cout<< xn1 << " " << xn2 <<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    res();
    return 0;
}