#include using namespace std; vector> matrix_multiplication(vector> A, vector> B){ int N = A.size(); vector> ans(N, vector(N, 0)); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ for (int k = 0; k < N; k++){ ans[i][k] ^= A[i][j] * B[j][k]; } } } return ans; } vector> matrix_exponentiation(vector> A, long long n){ int N = A.size(); vector> ans(N, vector(N, 0)); for (int i = 0; i < N; i++){ ans[i][i] = 1; } while (n > 0){ if (n % 2 == 1){ ans = matrix_multiplication(ans, A); } A = matrix_multiplication(A, A); n /= 2; } return ans; } int main(){ int N; long long K; cin >> N >> K; K--; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } if (K < N){ cout << A[K] << endl; } else { vector> B(N, vector(N, 0)); for (int i = 0; i < N; i++){ B[i][0] = 1; } for (int i = 0; i < N - 1; i++){ B[i][i + 1] = 1; } B = matrix_exponentiation(B, K - N + 1); long long ans = 0; for (int i = 0; i < N; i++){ if (B[i][0] == 1){ ans ^= A[N - 1 - i]; } } cout << ans << endl; } }