#define PROB Training #include #include #include using std::sort; #include #include typedef std::pair PII; #define f(x,y,z) for(int x = (y),__ = (z);x < __;++x) #define g(x,y,z) for(int x = (y),__ = (z);x <= __;++x) #define gd(x,y,z) for(int x = (y),__ = (z);x >= __;--x) #define CLR(X) memset(X,0,sizeof(X)) #define SET(ARR,X) memset(ARR,X,sizeof(ARR)) #define R(X,Y) f(X,0,Y) #define G(x,y) g(X,0,Y) #define MAXN 1024 #ifdef WIN32 #define LLD "%I64d" #define LLU "%I64u" #else #define LLD "%lld" #define LLU "%llu" #endif typedef long long LL; typedef long double real; int t,n; int a; int b[MAXN]; int num,cnt,ans; inline void solve(){ ans = 100; f(i,0,1LL << n){ num = a;cnt = 0; // puts(""); f(j,0,n)if (i & (1 << j)){ ++cnt; // printf("%d ",b[j]); num = num % b[j]; if (num == 0){ if (cnt <= ans)ans = cnt; break; } } } if (ans != 100)printf("%d\n",ans); else puts("-1"); } inline bool cmp(int x,int y){ return x > y; } int main(){ scanf("%d",&t); while (t--){ scanf("%d%d",&n,&a); f(i,0,n)scanf("%d",b + i); std::sort(b,b + n,cmp); solve(); } return 0; }