#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
long long t;
int main() {
  long long a, b, c, d, e, f, g, i, j;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    g = 0;
    map<long long, long long> mp;
    set<long long> st;
    f = 0;
    for (i = 0; i < b; i++) {
      cin >> c;
      f += c;
      mp[c]++;
    }
    if (a > f) {
      cout << " -1" << endl;
      continue;
    }
    for (i = 0;; i++) {
      d = pow(2, i);
      if (d > a) break;
      if (a & d) {
        if (mp[d] == 0) {
          while (1) {
            d *= 2;
            g++;
            if (mp[d] != 0) {
              mp[d]--;
              break;
            }
            ++i;
          }
        } else {
          mp[d]--;
          mp[d * 2] += (mp[d] / 2);
        }
      } else {
        mp[d * 2] += (mp[d] / 2);
      }
    }
    cout << g << endl;
  }
}
