Hamming Distance

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Helena has generated a list of sequences:

S1= \[1] S2 = S1 + \[2] + S1 S3 = S2 + \[3] + S2  Sm = Sm1 + \[m] + Sm1\begin{aligned} S^1 &=&  \[1] \\\ S^2  &=&  S^1  +  \[2]  +  S^1 \\\ S^3  &=&  S^2  +  \[3]  +  S^2 \\\ &\dots& \\\ S^m  &=&  S^{m-1}  +  \[m]  +  S^{m-1} \end{aligned}

where A+BA+B means the concatenation of two sequences AA and BB.

For a given sequence \[a_1,a_2,,a_n]\[a\_1,a\_2,\dots,a\_n], let f(i)f(i) be the Hamming distance between \[a_1,a_2,,a_n]\[a\_1,a\_2,\dots,a\_n] and \[Sm_i,Sm_i+1,,Sm_i+n1]\[S^m\_i, S^m\_{i+1}, \ldots, S^m\_{i+n-1}] (1iSmn+1)1 \le i \le |S^m| - n + 1)

Helena would like to find the minimum value of f(i)f(i) and the sum of f(i)f(i) modulo (109+7)(10^9+7).

Note that the Hamming distance between two sequences of equal length is the number of positions at which the corresponding elements are different.

입력

The input consists of several test cases terminated by end-of-file.

The first line contains two integers nn and mm.

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n.

출력

For each test case, output two integers denoting the minimum value of f(i)f(i) and the sum of f(i)f(i) modulo (109+7)(10^9+7).

제한

  • 1m1051 \le m \leq 10^5
  • 1nmin(Sm,105)1 \leq n \leq \min(|S^m|, 10^5)
  • 1a_im1 \leq a\_i \leq m
  • The sum of nn does not exceed 2×1062 \times 10^6.