This page is still under construction.

Parts of this page are still being built. What you see may change.

Mluran Storage

Time limit2sMemory limit256 MB

Summary
Count the ways to 2-color isotopes 1..n so that no two masses summing to a given power-of-two critical number share a color, mod 1e9+7.
Level

Hard8 of 10

Topics
Graph, Math, Combinatorics, Implementation
Solved
No attempts yet

Problem

Mluran, a chemical element discovered in 2345, is highly radioactive. Mishandling mluran can lead to unpredictable consequences, so special care must be taken when using, storing, and transporting it.

There are many different isotopes of mluran, each characterized by a natural number, its atomic mass. When any pair of isotopes whose masses sum to one of kk "critical numbers" is stored together for a long time, the pair reacts and explodes. All critical numbers are nonnegative powers of two.

At the nuclear laboratory of Flatland, mluran samples are stored in two special warehouses. Scientists have obtained nn different mluran isotopes whose masses are the numbers from 1 to nn. Now these isotopes must be distributed among the warehouses for storage. A storage method is called safe if each isotope is stored in exactly one warehouse and any two different isotopes whose masses sum to one of the "critical numbers" are stored in different warehouses.

Help the scientists find out how many different safe ways to store mluran exist.

Input

The input contains several test sets. Each set is described by two lines.

The first line of the description contains two integers nn and kk (1≤n≤10181 \le n \le 10^{18}, 1≤k≤611 \le k \le 61), the number of isotopes to store and the number of "critical numbers". The next line contains kk different natural numbers, each a power of two and not exceeding 2n2n, the critical numbers. The critical numbers are separated by spaces.

The number of data sets in each test does not exceed 10000. The last line of the test contains two zeros.

Output

For each test set, output on a separate line the number of safe ways to store all isotopes in two warehouses, modulo 109+710^9 + 7.

Examples1

  1. Example 1

    Input
    5 1
    1
    4 2
    4 2
    0 0
    
    Expected output
    32
    8