#line 1 "..\\Main.cpp" #include #include #include #include #include #line 4 "D:\\Programming\\VSCode\\competitive-cpp\\nachia\\misc\\bit-operations.hpp" namespace nachia{ int Popcount(unsigned long long c) noexcept { #ifdef __GNUC__ return __builtin_popcountll(c); #else c = (c & (~0ull/3)) + ((c >> 1) & (~0ull/3)); c = (c & (~0ull/5)) + ((c >> 2) & (~0ull/5)); c = (c & (~0ull/17)) + ((c >> 4) & (~0ull/17)); c = (c * (~0ull/257)) >> 56; return c; #endif } // please ensure x != 0 int MsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return 63 - __builtin_clzll(x); #else int res = 0; for(int d=32; d>0; d>>=1) if(x >> d){ res |= d; x >>= d; } return res; #endif } // please ensure x != 0 int LsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return __builtin_ctzll(x); #else return MsbIndex(x & -x); #endif } } #line 7 "..\\Main.cpp" using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main(){ int T; cin >> T; rep(t,T){ int N; cin >> N; int M; cin >> M; vector A(N); rep(i,N) cin >> A[i]; if(M * 2 + 2 <= N){ int res = 0; rep(i,N) if(nachia::Popcount(i & (N-1)) % 2 == 0) res ^= (A[i] & 1); cout << res << '\n'; } else{ for(int j=N-1; j>=1; j--) for(int k=0; k