#P6394. 樱花,还有你

樱花,还有你

Description

Sentences related to the task have been bolded.

But don’t rush. Let’s just keep walking slowly like this. No need to stop or look back. Aren’t there still kk sakura trees ahead? I calculated it: you need to collect exactly nn sakura petals. I also found that under the ii-th tree, you can collect at most sis_i sakura petals (collecting 00 sakura petals also counts as collecting sakura petals).

Now, let me test you. How many different plans are there to collect exactly nn sakura petals?

In particular, if you cannot collect nn sakura petals, please tell me impossible.

Note: If you reach nn sakura petals early, you may tell me immediately, or you may keep walking with me. But after collecting sakura petals under the kk-th tree, you must report your result. During the process, if you tell me after collecting sakura petals under any tree, the resulting plans are considered different.

Input Format

The first line contains two positive integers n,kn, k, meaning you need to collect nn sakura petals, and there are kk sakura trees ahead.

The next line contains kk positive integers s1,s2,,sks_1, s_2, \cdots, s_k, where sis_i means you can collect at most sis_i sakura petals under the ii-th sakura tree.

Output Format

Output one integer per line, representing the number of plans to collect exactly nn sakura petals.

Since the answer may be very large, output the result modulo 1008600110086001.

In particular, if it is impossible to collect nn sakura petals, output the string impossible.

3 4
1 1 1 1
5
10 9
9 6 8 7 9 6 5 4 3
68345
10 5
2 2 2 2 1
impossible

Hint

Sample Explanation #1

We use the following way to represent a plan: (a1,a2,,alen)(a_1, a_2, \cdots, a_{len}), where i=1lenai=n\sum_{i=1}^{len} a_i = n, lenlen means you report after finishing collecting sakura petals under the lenlen-th tree, and aia_i means you collected aia_i sakura petals under the ii-th tree.

Then there are 55 plans: (1,1,1)(1,1,1), (1,1,1,0)(1,1,1,0), (0,1,1,1)(0,1,1,1), (1,0,1,1)(1,0,1,1), (1,1,0,1)(1,1,0,1).


Sample Explanation #3

You can collect at most 99 sakura petals, so you cannot collect 1010 sakura petals, and the output is impossible.


Constraints

This problem uses bundled tests.

  • Subtask 1 (5 Points), si<n\sum s_i < n.
  • Subtask 2 (20 Points), n,k20n, k \leq 20.
  • Subtask 3 (55 Points), n,k5×102n, k \leq 5 \times 10^2.
  • Subtask 4 (20 Points), n,k5×103n, k \leq 5 \times 10^3.

For 100%100\% of the testdata, 1n,k5×1031 \leq n, k \leq 5 \times 10^3, 0sin0 \leq s_i \leq n.


Background (Continued)

  Someone as smart as you will surely stand under some tree, holding nn lovely sakura petals, and ask for credit from me like a child.
  Then don’t blame me for granting your wish. I will lightly jump up, wrap my arms around your neck, lift your mask, and taste your lips.
  Will you say, “Sweet like sakura”?
  Anyway, my face must already be as red as sakura.
  ...
  When you read this letter, don’t cry...
  What winter took away from this city, spring will make up for us.
  When you get better, go watch sakura with me, okay?

Yours,
Yi

Translated by ChatGPT 5