#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n, q;
int d[N], p[N];
int ans = INT_MAX;

int solve(int i, int h, int s)
{
    if(i == n && h > 0) return INT_MAX;

    if(h <= 0) {
        return i;
    }

    return min(solve(i + 1, h - d[i] - s, s), solve(i + 1, h - (s + p[i]), s + p[i]));
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> q;
    for(int i = 0; i < n; ++i) cin >> d[i] >> p[i];

    for(int i = 0, h; i < q; ++i)
    {
        cin >> h;
        int res = solve(0, h, 0);
        cout << ((res == INT_MAX)? -1 : res) << "\n";
    }
}