#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int((x).size())) #define bit(x) (1 << (x)) #define cnt1(x) (__builtin_popcount(x)) template inline void chkmax(T& x, T y) { if (x < y) x = y; } template inline void chkmin(T& x, T y) { if (y < x) x = y; } typedef long long LL; typedef double DB; typedef pair PII; typedef vector VI; const int MX = 25; int n, a; int b[MX]; int calc(int k, int r) { if (!r) return 0; if (k == n) return MX; return min(calc(k + 1, r), 1 + calc(k + 1, r % b[k])); } int main() { int tc, i, rlt; for (scanf("%d", &tc); tc--; ) { scanf("%d%d", &n, &a); for (i = 0; i < n; i++) scanf("%d", &b[i]); sort(b, b + n); n = unique(b, b + n) - b; reverse(b, b + n); rlt = calc(0, a); if (rlt == MX) rlt = -1; printf("%d\n", rlt); } return 0; }