#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e9;
int N, Q;
int D[maxN], P[maxN];
int dp[maxN][maxN];

int dfs(int H, int pSum, int t) {
    if (H <= 0) return t;
    if (t > N)return INT_MAX;
    if (dp[H][t] != -1)return dp[H][t];
    dp[H][t] = min(dfs(H - (D[t] + pSum), pSum, t+1),
    dfs(H - (pSum + P[t]), pSum + P[t], t+1));
    return dp[H][t];
}


void solve() {
    cin>>N>>Q;
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<N;++i)cin>>D[i]>>P[i];
    for(int i=0;i<Q;++i) {
        int H;
        cin>>H;
        int ans = dfs(H, 0, 0);
        if (ans <= N)cout<<ans<<"\n";
        else cout<<"-1\n";
    }
}

int main(void){
    ios::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}