#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long mod) {
  long long sum = 1;
  while (b) {
    if (b & 1) {
      sum = (sum * a) % mod;
      b--;
    }
    b /= 2;
    a = a * a % mod;
  }
  return sum;
}
const double Pi = acos(-1.0);
const double epsilon = Pi / 180.0;
const int maxn = 2e5 + 10;
long long mi[100], vis[100];
int main() {
  long long sum = 1;
  mi[0] = 1;
  int tail = 1;
  for (int i = 1; i <= 2000; i++) {
    sum *= 2;
    if (sum > 1e18) {
      tail = i;
      break;
    }
    mi[i] = sum;
  }
  int _;
  scanf("%d", &_);
  while (_--) {
    memset(vis, 0, sizeof(vis));
    long long n, m;
    cin >> n >> m;
    while (n) {
      int tmp = upper_bound(mi, mi + 1 + tail, n) - mi;
      tmp--;
      n -= mi[tmp];
      vis[tmp] -= 1;
    }
    for (int i = 1; i <= m; i++) {
      long long x;
      cin >> x;
      int tmp = lower_bound(mi, mi + 1 + tail, x) - mi;
      vis[tmp]++;
    }
    double cnt = 0;
    int ans = 0;
    for (int i = 0; i <= 70; i++) {
      cnt /= 2;
      cnt += vis[i];
      if (cnt < 0) ans++;
    }
    if (cnt < 0)
      cout << -1 << '\n';
    else
      cout << ans << '\n';
  }
}
