#include <bits/stdc++.h>
using namespace std;
struct cmp {
  bool operator()(long long i, long long j) const { return i > j; }
};
multiset<long long, cmp> s;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, m;
    cin >> n >> m;
    long long sum = 0;
    s.clear();
    for (long long i = 0; i < m; i++) {
      long long k;
      cin >> k;
      sum += k;
      s.insert(k);
    }
    long long ans = 0;
    for (auto it = s.begin(); it != s.end();) {
      long long val = *it;
      sum -= val;
      if (sum >= n) {
        it++;
        continue;
      }
      if (val <= n)
        n -= val;
      else {
        sum += val;
        val /= 2;
        it = s.erase(it);
        s.insert(val);
        s.insert(val);
        it = s.lower_bound(val);
        ans++;
        continue;
      }
      it++;
    }
    if (n != 0) ans = -1;
    cout << ans << '\n';
  }
  return 0;
}
