#include <bits/stdc++.h>
const int fx[] = {+1, -1, +0, +0};
const int fy[] = {+0, +0, +1, -1};
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    int m;
    cin >> n >> m;
    long long arr[m];
    for (int i = 0; i < m; i++) cin >> arr[i];
    sort(arr, arr + m);
    priority_queue<long long> q;
    long long sum = 0;
    for (int i = 0; i < m && sum < n; i++) {
      q.push(arr[i]);
      sum += arr[i];
    }
    long long sumc = 0;
    long long rem = n;
    long long ans = 0;
    while (!q.empty() && sumc < n) {
      long long u = q.top();
      q.pop();
      sum -= u;
      if (u + sumc > n) {
        if (sum < rem) {
          ans++;
          {
            q.push(u / 2);
            sum += u / 2;
          }
          if (sum < rem) {
            q.push(u / 2);
            sum += u / 2;
          }
        }
      } else {
        sumc += u;
        rem -= u;
      }
    }
    if (sumc < n)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}
