#include <bits/stdc++.h>
using namespace std;
void speed() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void solve() {
  vector<long long> p(61);
  p[0] = 1;
  for (int i = 1; i < int(61); ++i) {
    p[i] = p[i - 1] * 2;
  }
  map<long long, long long> m;
  long long n, k;
  cin >> k >> n;
  long long a[n];
  for (int i = 0; i < int(n); ++i) {
    cin >> a[i];
    m[a[i]]++;
  }
  long long sum = 0;
  for (int i = 0; i < int(n); ++i) {
    sum += a[i];
  }
  if (sum < k) {
    cout << "-1"
         << "\n";
    return;
  }
  long long ans = 0;
  for (int i = 0; i < int(61); ++i) {
    long long temp = p[i];
    if ((k & temp)) {
      if (m[temp] > 0) {
        m[temp]--;
      } else {
        for (int j = i + 1; j < int(61); ++j) {
          long long x = p[j];
          if (m[x] > 0) {
            while (x >= temp) {
              m[x]--;
              x = x / 2;
              ans++;
              m[x] += 2;
              if (m[temp] > 0) break;
            }
            m[temp]--;
            break;
          } else {
            continue;
          }
        }
      }
    }
    if (m[temp] != 0) {
      m[temp * 2] = m[temp * 2] + m[temp] / 2;
      m[temp] = m[temp] % 2;
    }
  }
  cout << ans << "\n";
}
int main() {
  speed();
  int tc = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
}
