#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } void solve() { int n; long long x; cin >> n >> x; vector c; for (int i = 0; i < n; i++) { int a; cin >> a; if (x & (1LL << a)) { continue; } c.push_back(a); } if (c.empty()) { cout << 0 << endl; return; } for (int i = c.back() + 1; i <= 60; i++) { if (x & (1LL << i)) { x ^= (1LL << i); } } long long ans = (1LL << c.back()); cout << 2 * (ans - x) << endl; } int main() { fast_io(); int t; cin >> t; for (; t--;) { solve(); } }