#include <bits/stdc++.h>
using namespace std;

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

template<class T> inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

unordered_set<ll> s[61];

void Main() {
  int N1, N2, M;
  scanf("%d%d%d", &N1, &N2, &M);
  vi A(M);
  rep(i, M) scanf("%d", &A[i]);

  sort(ALL(A));

  const ll D = 1000000;
  s[0].insert(N1 * D + N2);

  rep(i, M) {
    int a = A[i];
    bool ok = 0;
    forr(x, s[i]) {
      if (x >= a * D) {
        s[i+1].insert(x - a * D);
        ok = 1;
      }
      if (x % D >= a) {
        s[i+1].insert(x - a);
        ok = 1;
      }
    }
    if (!ok) {
      _p("%d\n", i);
      return;
    }
  }
  _p("%d\n", M);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) Main();
  return 0;
}