Under construction

Still being built. Things may change

Sum Mod Pair of A

Time limit1.5sMemory limit1024 MB

Summary
Given array A and a power of 2 M, find the sum of all elements of SMPA^K(A, M) modulo 998244353 when K can be as large as 10^9.
Level

Medium6 of 10

Topics
Math, Number theory, Array
Solved
No attempts yet

Statement

Jono likes arrays. He is especially interested in one operation on an array, which he calls Sum Mod Pair of A, or SMPA for short.

Given an array of integers AA (indexed from 00 to N−1N - 1) and an integer MM that is a power of 22, the operation SMPA(A,M)\text{SMPA}(A, M) returns an array of size N2N^2 (indexed from 00 to N2−1N^2-1). Its iith element is (Ax+Ay) mod M(A_x+A_y) \bmod M, where x=⌊i/N⌋x = \lfloor i/N \rfloor and y=i mod Ny = i \bmod N.

For example, let AA be {2, 4, 5} and M=8M = 8. Then SMPA(A,M)\text{SMPA}(A, M) is {4, 6, 7, 6, 0, 1, 7, 1, 2}.

Jono is not satisfied with one SMPA operation. He defines SMPAK\text{SMPA}^K for a positive integer KK as follows. If K=1K = 1, SMPAK(A,M)=SMPA(A,M)\text{SMPA}^K(A, M) = \text{SMPA}(A, M). Otherwise, SMPAK(A,M)=SMPAK−1(SMPA(A,M),M)\text{SMPA}^K(A, M) = \text{SMPA}^{K-1}(\text{SMPA}(A, M), M).

For example, let AA be {1, 2} and M=8M = 8. Then SMPA1(A,M)\text{SMPA}^1(A, M) is {2, 3, 3, 4}, and SMPA2(A,M)\text{SMPA}^2(A, M) is {4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 0}.

The array size grows exponentially, so Jono cannot print the result. He only needs the sum of all elements of SMPAK(A,M)\text{SMPA}^K(A, M). Compute that sum modulo 998244353.

Input

The first line contains three integers NN, MM, and KK (1≤N≤1000001 \le N \le 100000, M∈{20,21,…,218}M \in \{2^0, 2^1, \dots, 2^{18}\}, 1≤K≤1091 \le K \le 10^9). The next line contains NN integers AiA_i (0≤Ai<M0 \le A_i < M), the elements of array AA.

Output

Print one integer on a line: the non-negative remainder of the sum of all elements of SMPAK(A,M)\text{SMPA}^K(A, M) divided by 998244353.

Examples3

  1. Example 1

    Input
    3 8 1
    0 1 2
    
    Expected output
    18
    
  2. Example 2

    Input
    3 8 2
    0 1 2
    
    Expected output
    316
    
  3. Example 3

    Input
    5 8192 3
    1000 2000 3000 4000 5000
    
    Expected output
    577938879