Kozak Vus and Colors
Cossack Vus recently discovered stones lined up in a row. He also has different paints, each uniquely numbered from to .
His goal is to paint the stones such that no two adjacent stones share the same color. However, some stones have already been painted, and these cannot be repainted.
Cossack Vus wants to know how many different ways he can paint the stones while adhering to these conditions. Since the number of possible ways can be very large, you should provide the result modulo .
Input
The first line contains two integers and () — representing the number of stones and the number of available colors, respectively.
The second line contains integers () — indicating the colors of the stones. If , the stone is not yet painted. If , the stone is already painted with the color numbered .
Output
Output a single integer — the number of ways to paint the stones, calculated modulo .
Examples
Scoring
( points): ;
( points): ;
( points): ;
( points): ;
( points): no additional constraints.