#P979E. Kuro and Topological Parity

Kuro and Topological Parity

No submission language available for this problem.

Description

Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.

Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot of arrows (you can assume that the number of arrows is infinite). Immediately, Katie came up with the game called Topological Parity.

The paper is divided into nn pieces enumerated from 11 to nn. Shiro has painted some pieces with some color. Specifically, the ii-th piece has color cic_{i} where ci=0c_{i} = 0 defines black color, ci=1c_{i} = 1 defines white color and ci=1c_{i} = -1 means that the piece hasn't been colored yet.

The rules of the game is simple. Players must put some arrows between some pairs of different pieces in such a way that for each arrow, the number in the piece it starts from is less than the number of the piece it ends at. Also, two different pieces can only be connected by at most one arrow. After that the players must choose the color (00 or 11) for each of the unpainted pieces. The score of a valid way of putting the arrows and coloring pieces is defined as the number of paths of pieces of alternating colors. For example, [1010][1 \to 0 \to 1 \to 0], [0101][0 \to 1 \to 0 \to 1], [1][1], [0][0] are valid paths and will be counted. You can only travel from piece xx to piece yy if and only if there is an arrow from xx to yy.

But Kuro is not fun yet. He loves parity. Let's call his favorite parity pp where p=0p = 0 stands for "even" and p=1p = 1 stands for "odd". He wants to put the arrows and choose colors in such a way that the score has the parity of pp.

It seems like there will be so many ways which satisfy Kuro. He wants to count the number of them but this could be a very large number. Let's help him with his problem, but print it modulo 109+710^{9} + 7.

The first line contains two integers nn and pp (1n501 \leq n \leq 50, 0p10 \leq p \leq 1) — the number of pieces and Kuro's wanted parity.

The second line contains nn integers c1,c2,...,cnc_{1}, c_{2}, ..., c_{n} (1ci1-1 \leq c_{i} \leq 1) — the colors of the pieces.

Print a single integer — the number of ways to put the arrows and choose colors so the number of valid paths of alternating colors has the parity of pp.

Input

The first line contains two integers nn and pp (1n501 \leq n \leq 50, 0p10 \leq p \leq 1) — the number of pieces and Kuro's wanted parity.

The second line contains nn integers c1,c2,...,cnc_{1}, c_{2}, ..., c_{n} (1ci1-1 \leq c_{i} \leq 1) — the colors of the pieces.

Output

Print a single integer — the number of ways to put the arrows and choose colors so the number of valid paths of alternating colors has the parity of pp.

Samples

Sample Input 1

3 1
-1 0 1

Sample Output 1

6

Sample Input 2

2 1
1 0

Sample Output 2

1

Sample Input 3

1 1
-1

Sample Output 3

2

Note

In the first example, there are 66 ways to color the pieces and add the arrows, as are shown in the figure below. The scores are 3,3,53, 3, 5 for the first row and 5,3,35, 3, 3 for the second row, both from left to right.