402901: GYM100942 B High-Speed Pedestrian walkway 1.0

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. High-Speed Pedestrian walkway 1.0time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Construction of the High-Speed Pedestrian walkway that connects two capitals was ordered by the Department for Innovation. But nobody knew how to construct it. Fortunately, there is a unique plant in the city for pedestrian walkway components production.

The plant produces m types of tiles – rectangles of 1 × k cm, available in ck different colors,1 ≤ k ≤ m.

The pedestrian walkway consists of a rectangular segments of 2 × n cm. Each segment in the construction is assembled with tiles of above mentioned kind. Since the completion of the pedestrian walkway will be accepted by the top Heads, so it was decided to construct it from unique segments, in other words, all segments should be different in way of tiling.

Now it is important to find out what the maximum possible number of unique segments is.

Input

The first line contains integers n and m (1 ≤ n ≤ 1018,  1 ≤ m ≤ 9) — length of a segment and number of tiles' kinds. The second line contains space separated m non-negative integers c1, c2, ..., cm, at least one of which is different from zero. All integers do not exceed 109.

Output

Output the required number modulo (109 + 9).

ExamplesInput
3 3
0 1 2
Output
7 
Input
2 4
0 0 1 0
Output
0

加入题单

算法标签: