#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e5 + 6;
int cnt[65];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    cnt[__builtin_ctz(x)]++;
  }
  int cur = 0, ans = 0;
  for (; n; n /= 2, cur++) {
    bool paisi = false;
    if (cnt[cur]) {
      paisi = true;
      cnt[cur] -= n % 2;
      cnt[cur + 1] += cnt[cur] / 2;
      continue;
    }
    if (n % 2 == 0 or paisi) continue;
    for (int i = cur + 1; i < 65; i++) {
      if (cnt[i]) {
        for (int j = i; j > cur; j--) {
          cnt[j]--;
          cnt[j - 1] += 2;
          ans++;
        }
        paisi = true;
        break;
      }
    }
    if (!paisi) {
      cout << "-1\n";
      return;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
    memset(cnt, 0, sizeof cnt);
  }
}
