#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ls id<<1,l,mid #define rs id<<1|1,mid+1,r #define OFF(x) memset(x,-1,sizeof x) #define CLR(x) memset(x,0,sizeof x) #define MEM(x) memset(x,0x3f,sizeof x) typedef long long ll ; typedef pair pii ; const int maxn = 1e5+50 ; const int inf = 0x3f3f3f3f ; const int MOD = 1e9+7 ; int n,a,num[50],ans; int vis[50]; bool cmp(const int &a,const int &b) {return a>b;} void dfs(int now,int step) { if (step>=n) return ; for (int i=0;inow||vis[i]) continue ; if (now%num[i]==0) { ans=min(ans,step+1); } vis[i]=1; dfs(now%num[i],step+1); vis[i]=0; } } int main () { #ifdef LOCAL freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin); // freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout); #endif int T; scanf("%d",&T); while (T--) { CLR(vis); ans=inf; scanf("%d%d",&n,&a); for (int i=0;i1000000) printf("-1\n"); else printf("%d\n",ans); } return 0; }