#abc367g. G - Sum of (XOR^K or 0)

G - Sum of (XOR^K or 0)

Score : 675675 points

问题陈述

给定正整数 NN, MM, KK,以及一个非负整数序列:A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N)

对于一个非空非负整数序列 B=(B1,B2,,BB)B=(B_1,B_2,\ldots,B_{|B|}),我们定义它的得分如下。

  • 如果 BB 的长度是 MM 的倍数:(B1B2BB)K(B_1 \oplus B_2 \oplus \dots \oplus B_{|B|})^K
  • 否则:00

这里,\oplus 表示按位异或。

找出 AA2N12^N-1 个非空子序列的得分之和,对 998244353998244353 取模。

什么是按位异或?非负整数 AABB 的按位异或,记作 ABA \oplus B,定义如下:

  • ABA \oplus B 的二进制表示中,位置 2k2^kk0k \geq 0)的数字是 11,如果 AABB 的二进制表示中恰好有一个在该位置有 11,否则是 00

例如,35=63 \oplus 5 = 6(二进制:011101=110011 \oplus 101 = 110)。 一般来说,kk 个整数 p1,,pkp_1, \dots, p_k 的异或定义为 $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$,可以证明这与 p1,,pkp_1, \dots, p_k 的顺序无关。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

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

For a non-empty non-negative integer sequence B=(B1,B2,,BB)B=(B_1,B_2,\ldots,B_{|B|}), we define its score as follows.

  • If the length of BB is a multiple of MM: (B1B2BB)K(B_1 \oplus B_2 \oplus \dots \oplus B_{|B|})^K
  • Otherwise: 00

Here, \oplus represents the bitwise XOR.

Find the sum, modulo 998244353998244353, of the scores of the 2N12^N-1 non-empty subsequences of AA.

What is bitwise XOR? The bitwise XOR of non-negative integers AA and BB, denoted as ABA \oplus B, is defined as follows:

  • In the binary representation of ABA \oplus B, the digit at position 2k2^k (k0k \geq 0) is 11 if exactly one of AA and BB has a 11 in that position in their binary representations, and 00 otherwise.

For example, 35=63 \oplus 5 = 6 (in binary: 011101=110011 \oplus 101 = 110).
In general, the XOR of kk integers p1,,pkp_1, \dots, p_k is defined as $(\cdots ((p_1 \oplus p_2) \oplus p_3) \oplus \cdots \oplus p_k)$, and it can be proved that this is independent of the order of p1,,pkp_1, \dots, p_k.

Constraints

  • 1N,K2×1051 \leq N,K \leq 2 \times 10^5
  • 1M1001 \leq M \leq 100
  • 0Ai<2200 \leq A_i < 2^{20}
  • All input values are integers.

Input

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

NN MM KK

A1A_1 A2A_2 \ldots ANA_N

Output

Print the answer.

Sample Input 1

3 2 2
1 2 3

Sample Output 1

14

Here are the scores of the 231=72^3-1=7 non-empty subsequences of AA.

  • (1)(1): 00
  • (2)(2): 00
  • (3)(3): 00
  • (1,2)(1,2): (12)2=9(1\oplus2)^2=9
  • (1,3)(1,3): (13)2=4(1\oplus3)^2=4
  • (2,3)(2,3): (23)2=1(2\oplus3)^2=1
  • (1,2,3)(1,2,3): 00

Therefore, the sought sum is 0+0+0+9+4+1+0=140+0+0+9+4+1+0=14.

Sample Input 2

10 5 3
100 100 100 100 100 100 100 100 100 100

Sample Output 2

252000000

Sample Input 3

16 4 100
7053 3876 3178 8422 7802 5998 2334 6757 6889 6637 7365 9495 7848 9026 7312 6558

Sample Output 3

432440016