#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#ifndef ONLINE_JUDGE
#include "Ash.cpp"
#else
#define dbg(...)
#define dbgA(...)
#endif
void solve(int cs) {
int n, x;
cin >> n >> x;
int mx = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
mx = max(mx, a[i]);
}
if (x == 1) {
cout << "1\n";
return;
}
unordered_map<int, int> seen;
for (auto &it : a) seen[it] += 1;
pair<int64_t,int> res = {1e13,-1};
auto check = [&](int k) -> void {
int cnt = 0;
int64_t sum = 0;
for (int i = k; i <= mx; i += k) {
if (seen[i] > 0) {
sum += i * seen[i];
}
}
if (res.first > sum) {
res.first = sum;
res.second = k;
}
};
for (int i = 1; i <= x; i++) {
check(i);
}
cout << res.second << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
cin >> tc;
for (int cs = 1; cs <= tc; cs++) {
solve(cs);
}
return 0;
}