//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#include <iterator>
#include <math.h>
#include <set>
#include <functional>
#include <fstream>
#include <chrono>
#include <random>
#include <assert.h>

#define all(x) begin(x), end(x)
#define isz(x) int(size(x))
#define forx(x, n) for(int x = 0; x < n; ++x)
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using ll = long long;
using ull = unsigned long long;
using real = long double;
using uint = unsigned int;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vvvpii = vector<vvpii>;

const auto ready = []()
{
	cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	return true;
}();

int solve(const int monster_hp, const int n, const vector<int>& hero_hp, const vector<int>& hero_dmg)
{
	const int inf = int(1e9);
	vector<pair<int, int>> hero_pair(n);
	for (int i = 0; i < n; ++i)
	{
		hero_pair[i].first = hero_hp[i];
		hero_pair[i].second = hero_dmg[i];
	}
	std::sort(hero_pair.begin(), hero_pair.end());
	std::reverse(hero_pair.begin(), hero_pair.end());
	std::multiset<int> dmgs;
	dmgs.insert(0);
	auto min_dmg = dmgs.begin();
	int current_hero = 0;
	int total_dmg = 0;
	int have_heroes = 1;
	int ans = inf;
	while (current_hero < n)
	{
		int min_hp = hero_pair[current_hero].first;
		int time = min_hp;
		int req_dmg = (monster_hp + time - 1) / time;
		while (current_hero < n && hero_pair[current_hero].first == min_hp)
		{
			int next_dmg = hero_pair[current_hero].second;
			dmgs.insert(next_dmg);
			if (next_dmg >= (*min_dmg))
			{
				total_dmg -= (*min_dmg);
				total_dmg += next_dmg;
				++min_dmg;
			}
			++current_hero;
			if((*dmgs.begin()) == 0) dmgs.erase(dmgs.begin());
		}
		if (ans == inf)
		{
			while (total_dmg < req_dmg && min_dmg != dmgs.begin())
			{
				--min_dmg;
				total_dmg += (*min_dmg);
				++have_heroes;
			}
		}
		while (total_dmg - (*min_dmg) >= req_dmg)
		{
			total_dmg -= (*min_dmg);
			++min_dmg;
			--have_heroes;
		}
		if (total_dmg >= req_dmg)
		{
			ans = std::min(ans, have_heroes);
		}
	}
	if(ans == inf) ans = -1;
	return ans;
}

int main()
{
    int monster_hp;
	int n;
	std::vector<int> hp, dmg;
	int t;
	cin >> t;
    for(int i = 0; i < t; ++i)
    {
		cin >> monster_hp;
		cin >> n;
		hp.resize(n);
		dmg.resize(n);
		for(int j = 0; j < n; ++j) cin >> hp[j];
		for(int j = 0; j < n; ++j) cin >> dmg[j];
		cout << solve(monster_hp, n, hp, dmg) << "\n";
    }
	return 0;
}