Performance Assessment 1

Find the shortest sequence over 1 to M missing as a contiguous block of A and count such sequences modulo 1e9+7.

Medium6String matchingHash mapCombinatoricsNo attempts yetTime limit1sMemory limit256 MB

Problem

Jaehyun handed in a sequence AA of length NN for his algorithm assignment. Every element of AA is a natural number at most MM. He calls a sequence beautiful when all of its elements are at most MM.

Jaehyun wants to hand in one more beautiful sequence BB of his own. Every element of BB is also a natural number between 11 and MM, and its length is at least 11. The teacher rules that BB is plagiarism if BB is a contiguous subsequence of AA, so BB must not appear inside AA as a contiguous block.

Jaehyun has no time left, so he wants BB to be as short as possible. Find the minimum length of a sequence BB that satisfies the condition, and the number of sequences of that length, modulo 109+710^9 + 7. A sequence of length N+1N + 1 can never appear inside AA as a contiguous block, so an answer always exists.

Input

The first line contains NN and MM, separated by a space. (1N,M1000001 \le N, M \le 100000)

The second line contains the elements A1,A2,,ANA_1, A_2, \dots, A_N of the sequence AA, separated by spaces. (1AiM1 \le A_i \le M)

Output

Print the minimum length of a sequence BB that satisfies the condition and the number of sequences of that length modulo 109+710^9 + 7, separated by a space.