/**************Powered by Graphene Richards**************/ //{ #define FLOAT_PRECISION 2 #ifdef _MSC_VER #define _SECURE_SCL 0 #pragma comment(linker,"/STACK:102400000,102400000") #else #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #endif #if defined(_MSC_VER)||__cplusplus>199711L #define IT(x) auto #define DIT(x) auto #else #define IT(x) __typeof((x).begin()) #define DIT(x) __typeof((x).rbegin()) #endif # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude # inc\ lude #define FAST_RW ios_base::sync_with_stdio(0),cin.tie(0); #define FS(i,a) for(ll i=0;a[i];i++) #define FE(it,x) for(IT(x) it=(x).begin(),_en=(x).end();it!=_en;it++) #define EF(it,x) for(DIT(x) it=(x).rbegin(),_en=(x).rend();it!=_en;it++) #define FR(i,en) for(ll i=0,_en=(en);i<_en;i++) #define FOR(i,en) for(ll i=1,_en=(en);i<=_en;i++) #define RF(i,en) for(ll i=(en)-1;i>=0;i--) #define ROF(i,en) for(ll i=(en);i>0;i--) #define FFR(i,x,y) for(ll i=(x),_en=(y);i<=_en;i++) #define RFF(i,x,y) for(ll i=(x),_en=(y);i>=_en;i--) #define pc putchar #define pb push_back #define ppb pop_back #define pq priority_queue #define fi first #define se second #define mp make_pair #define pii pair #define pll pair #define sqr(x) ((x)*(x)) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define clr(x) memset((x),0,sizeof(x)) #define ms(x,v) memset((x),(v),sizeof(x)) #define mc(x,y) memcpy((x),(y),sizeof(y)) #define NL puts(""); #define LB lower_bound #define UB upper_bound #define rand() ((rand()<<16)^(rand()<<15)^(rand())) #ifdef _WIN32 #define _i64_ "%I\ 64d" #define _u64_ "%I\ 64u" #else #define _i64_ "%l\ ld" #define _u64_ "%l\ lu" #endif typedef unsigned ui; typedef long long ll; typedef unsigned long long ull; typedef long double lf; using namespace std; ull gcd(ull a,ull b){if(!b)return a;while(b^=a^=b^=a%=b);return a;} extern const ll MOD; ll ksm(ll a,ll b){ ll res=1; a%=MOD; for(;b;b>>=1){ if(b&1)res=res*a%MOD; a=a*a%MOD; } return res; } #ifdef wmx16835 #include"wmx16835.h" #else #define LOG #define TEL #define test(...) 0 #define TEST(...) 0 #define TRY(...) #define SF(...) #define SC #define PF #define PC #define PP #define SHOW_TIME #define BR #endif #define y0 NKwKGuBIYOBJIYE #define y1 KFJssmlKWLKpHHC #define yn XypGISMRucIzhPW #define j1 kQDCYYWXStYQHfy #define tm BdKIQNcsUnPeYUI #define lr UsCPcJvtazINyXU templatebool In(T1 x,T2 y,T3 z){return x<=y&&x>=z||x<=z&&x>=y;} templateT1 max(const T1&a,const T2&b){return aT1 max3(const T1&a,const T2&b,const T3&c){return aT1 min(const T1&a,const T2&b){return aT1 min3(const T1&a,const T2&b,const T3&c){return abool S(pair&a){S(a.fi),S(a.se);} templatebool S(T&a){a.in();} void _P(const int&x){printf("%d",x);} void _P(const bool&x){printf("%d",x);} void _P(const ui&x){printf("%u",x);} void _P(const char&x){printf("%c",x);} void _P(const char*x){printf("%s",x);} void _P(const string&x){printf("%s",x.c_str());} void _P(const ll&x){printf(_i64_,x);} void _P(const ull&x){printf(_u64_,x);} void _P(const float&x){printf("%.*f",FLOAT_PRECISION,x);} void _P(const double&x){printf("%.*f",FLOAT_PRECISION,x);} void _P(const lf&x){printf("%.*f",FLOAT_PRECISION,(double)x);} templatevoid _P(const pair&x){_P(x.fi);pc(' ');_P(x.se);} templatevoid _P(const T&a){a.out();} templatebool S(T1&a,T2&b){return S(a)+S(b)==2;} templatebool S(T1&a,T2&b,T3&c){return S(a)+S(b)+S(c)==3;} templatebool S(T1&a,T2&b,T3&c,T4&d){return S(a)+S(b)+S(c)+S(d)==4;} templatebool S(T1&a,T2&b,T3&c,T4&d,T5&e){return S(a)+S(b)+S(c)+S(d)+S(e)==5;} templatevoid P(const T1&a){_P(a);pc(' ');} templatevoid P(const T1&a,const T2&b){_P(a);pc(' ');_P(b);pc(' ');} templatevoid PN(const T1&a){_P(a);NL} templatevoid PN(const T1&a,const T2&b){_P(a);pc(' ');_P(b);NL} templatevoid PN(const T1&a,const T2&b,const T3&c){_P(a);pc(' ');_P(b);pc(' ');_P(c);NL} templatevoid PN(const T1&a,const T2&b,const T3&c,const T4&d){_P(a);pc(' ');_P(b);pc(' ');_P(c);pc(' ');_P(d);NL} templatevoid PN(const T1&a,const T2&b,const T3&c,const T4&d,const T5&e){_P(a);pc(' ');_P(b);pc(' ');_P(c);pc(' ');_P(d);pc(' ');_P(e);NL} void PS(int a){printf("%*s",a,"");} templatevoid SA(T*a,int n){FR(i,n)S(a[i]);} templatevoid PA(T*a,int n){FR(i,n){if(i)pc(' ');_P(a[i]);}NL} templatevoid PA(const T&x){FE(it,x){if(it!=x.begin())pc(' ');_P(*it);}NL} int kase; const double pi=4*atan(1.); const double ep=1e-9; const int INF=0x3f3f3f3f; const ll INFL=0x3f3f3f3f3f3f3f3fll; const ll MOD=1000000007; //} int main(){ SHOW_TIME int T; S(T); while(T--){ int n,a,b[20]; S(n,a); FR(i,n)S(b[i]); sort(b,b+n,greater()); int res=INF; int cur; for(int i=0;i<1<>j&1)cur%=b[j]; } if(cur==0)res=min(res,__builtin_popcount(i)); } if(res!=INF)PN(res); else PN(-1); } } /*********Risoft corporation all rights reserved*********/ /**************Template V2.32 build 20150719*************/