#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>

#define int long long

using namespace std;

int naive1(const int monster_hp, const int n, const vector<int>& hero_hp, const vector<int>& hero_dmg)
{
    //assert(n <= 20);
	const int inf = 1'000'000'000;
	int ans = inf;
	for (int i = 1; i < (1 << n); ++i)
	{
		int mn_hp = 1'000'000'000;
		int total_dmg = 0;
		int have_heroes = 0;
		int ptr = 0;
		int j = i;
		while (j)
		{
			if (j & 1)
			{
				mn_hp = std::min(mn_hp, hero_hp[ptr]);
				total_dmg += hero_dmg[ptr];
				++have_heroes;
			}
			j >>= 1;
			++ptr;
		}
		int time = mn_hp;
		int req_dmg = (monster_hp + time - 1) / time;
		if (total_dmg >= req_dmg)
		{
			ans = std::min(ans, have_heroes);
		}
	}
	return (ans == inf ? -1 : ans);
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    int t; cin >> t;
    while (t--) {
        int a, n; cin >> a >> n;
        vector<int> hp(n), dmg(n);
        for (int i = 0; i < n; ++i)
            cin >> hp[i];
        for (int i = 0; i < n; ++i)
            cin >> dmg[i];
        cout << naive1(a, n, hp, dmg) << '\n';
    }
}