#include <bits/stdc++.h>
using namespace std;
const int maxN = 100010;
int m, A[maxN];
int D[64];
long long n;
void xl() {
  int ans = 0;
  memset(D, 0, sizeof(D));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < 63; ++j) {
      long long x = 1;
      x <<= j;
      if (x & A[i]) ++D[j];
    }
  }
  bool ok = true;
  for (int i = 0; i < 63; ++i) {
    long long x = 1;
    x <<= i;
    if (n & x) {
      if (D[i])
        --D[i];
      else {
        ok = false;
        for (int j = i + 1; j < 63; ++j) {
          if (D[j]) {
            --D[j];
            while (j > i) {
              ++ans;
              j -= 1;
              ++D[j];
            }
            ok = true;
            break;
          }
        }
      }
    }
    D[i + 1] += D[i] / 2;
  }
  if (!ok) ans = -1;
  printf("%d \n", ans);
}
int main() {
  int ntest;
  scanf("%d\n", &ntest);
  while (ntest--) {
    scanf("%lld%d\n", &n, &m);
    for (int i = 0; i < m; ++i) scanf("%d", &A[i]);
    long long sum = 0;
    for (int i = 0; i < m; ++i) sum += A[i];
    if (sum < n)
      printf("%d\n", -1);
    else
      xl();
  }
  return 0;
}
