#include <bits/stdc++.h>
using namespace std;
long long n;
int m, f[100], g[100];
inline void add(long long x, int f[]) {
  int i = 0;
  while (x) {
    if (x & 1) f[i]++;
    i++;
    x >>= 1;
  }
}
int main() {
  int tt = 0, ttt = 0;
  scanf("%d", &tt);
  while (tt--) {
    scanf("%lld%d", &n, &m);
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    add(n, g);
    long long sum = 0;
    for (int i = 1; i <= m; i++) {
      int a;
      scanf("%d", &a);
      add(a, f);
      sum += a;
    }
    if (sum < n) {
      puts("-1");
      continue;
    }
    int ans = 0;
    for (int i = 0; i < 60; i++) {
      if (g[i] > 0 && f[i] > 0) {
        g[i]--;
        f[i]--;
      }
      if (g[i] == 0) {
        f[i + 1] += f[i] / 2;
        f[i] %= 2;
        continue;
      }
      int j;
      for (j = i; j < 60; j++) {
        if (f[j] > 0) break;
      }
      f[j--]--;
      while (j >= i) f[j--] = 1, ans++;
      g[i] = 0;
    }
    printf("%d\n", ans);
  }
  return 0;
}
