#P1093F. Vasya and Array
Vasya and Array
Description
Vasya has got an array consisting of integers, and two integers and in addition. All numbers in the array are either between and (inclusive), or equal to . The array is good if there is no segment of consecutive equal numbers.
Vasya will replace each with some number from to (inclusive) in such a way that the resulting array is good. Tell him the number of ways to do this replacement. Since the answer may be large, print it modulo .
The first line contains three integers and ().
The second line contains numbers — the array. Each number is either or between and (inclusive).
Print one integer — the number of ways to replace each with some number from to (inclusive) so the array is good. The answer may be large, so print it modulo .
Input
The first line contains three integers and ().
The second line contains numbers — the array. Each number is either or between and (inclusive).
Output
Print one integer — the number of ways to replace each with some number from to (inclusive) so the array is good. The answer may be large, so print it modulo .
Note
Possible answers in the first test:
- ;
- .
There is no way to make the array good in the second test, since first two elements are equal.
There are too many answers in the third test, so we won't describe any of them.