Given are Nimbers a_1,a_2,…,a_K−1, b_1,b_2,…,b_5, and c_1,c_2,…,c_5.
Let a_n=(⨁_i=15a_n−i⊗b_i)⊕(⨁_i=15a_n−K+i⊗c_i) for all n≥K.
Find the value of a_m.
The first line of input contains two positive integers K and m (6≤K≤105, 1≤m≤1018).
The second line contains K−1 non-negative integers a_1,a_2,…,a_K−1 (0≤a_i<232).
The third line contains five non-negative integers b_1,b_2,…,b_5 (0≤b_i<232).
The fourth line contains five non-negative integers c_1,c_2,…,c_5 (0≤c_i<232).
Output a single line with a single integer: the value of a_m.
Nimbers are non-negative integers associated with Nim games. For the purposes of this problem, two operations are necessary:
Here, mex(S) represents the smallest non-negative integer d∈S.