#arc156d. [arc156_d]Xor Sum 5

[arc156_d]Xor Sum 5

Problem Statement

You are given a sequence of NN non-negative integers A=(A1,A2,dots,AN)A=(A_1,A_2,\\dots,A_N) and a positive integer KK.

Find the bitwise mathrmXOR\\mathrm{XOR} of displaystylesumi=1KAXi\\displaystyle \\sum_{i=1}^{K} A_{X_i} over all NKN^K sequences of KK positive integer sequences X=(X1,X2,dots,XK)X=(X_1,X_2,\\dots,X_K) such that 1leqXileqN(1leqileqK)1 \\leq X_i \\leq N\\ (1\\leq i \\leq K).

What is bitwise mathrmXOR\\mathrm{XOR}?

The bitwise mathrmXOR\\mathrm{XOR} of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows:

  • When AoplusBA \\oplus B is written in base two, the digit in the 2k2^k's place (kgeq0k \\geq 0) is 11 if exactly one of the digits in that place of AA and BB is 11, and 00 otherwise.

For example, we have 3oplus5=63 \\oplus 5 = 6 (in base two: 011oplus101=110011 \\oplus 101 = 110).
Generally, the bitwise mathrmXOR\\mathrm{XOR} of kk non-negative integers p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$. We can prove that this value does not depend on the order of p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k.

Constraints

  • 1leqNleq10001 \\leq N \\leq 1000
  • 1leqKleq10121 \\leq K \\leq 10^{12}
  • 0leqAileq10000 \\leq A_i \\leq 1000
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN KK A1A_1 A2A_2 dots\\dots ANA_N

Output

Print the answer.


Sample Input 1

2 2
10 30

Sample Output 1

40

There are four sequences to consider: (X1,X2)=(1,1),(1,2),(2,1),(2,2)(X_1,X_2)=(1,1),(1,2),(2,1),(2,2), for which AX1+AX2A_{X_1}+A_{X_2} is 20,40,40,6020,40,40,60, respectively. Thus, the answer is 20oplus40oplus40oplus60=4020 \\oplus 40 \\oplus 40 \\oplus 60=40.


Sample Input 2

4 10
0 0 0 0

Sample Output 2

0

Sample Input 3

11 998244353
314 159 265 358 979 323 846 264 338 327 950

Sample Output 3

236500026047