| OCPC 2023, Oleksandr Kulkov Contest 3 |
|---|
| Закончено |
Super Meat Bros is a manga about two brothers Meatio and Meatigi who ultimately love meat.
Signature feature of this manga is that both brothers have their own story arcs that progress independently. Each brother will have a story of zero or more arcs, each arc containing at most $$$n$$$ manga issues. For an arc that would last $$$k$$$ issues, the mangaka knows $$$a_k$$$ ways to make a story about Meatio and $$$b_k$$$ ways to make a story about Meatigi.
The mangaka will make two stories, one about Meatio and the other about Meatigi. The story about Meatio is created in the following way: Until the mangaka is bored, they choose a number $$$k \le n$$$ and append a new story arc of $$$k$$$ issues to the story in one of $$$a_k$$$ distinct ways. Correspondingly, for Meatigi story, the mangaka chooses $$$k$$$ and appends a new story arc of $$$k$$$ issues in one of $$$b_k$$$ distinct ways.
After full stories of several arcs are prepared for both Meatio and Meatigi, they will be merged together in a way that preserves internal order of stories. That is, if issues $$$x$$$ and $$$y$$$ are related to the same brother and in his story $$$x$$$ comes before $$$y$$$, it will also come before $$$y$$$ in the merged story. Other than that merging can be arbitrary, in particular story arcs do not have to form a contiguous subsequence.
You're given $$$a_1, \dots, a_n$$$ and $$$b_1, \dots, b_n$$$, calculate the number of ways to create a full volume of $$$m$$$ issues.
First line of input contains two integers $$$n$$$ ($$$1 \leq n \leq 300$$$) and $$$m$$$ ($$$1 \leq m \leq 10^9$$$).
Second line contains $$$n$$$ integers $$$a_1, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$).
Third line contains $$$n$$$ integers $$$b_1, \dots, b_n$$$ ($$$1 \leq b_i \leq 10^9$$$).
Output a single integer which is the number of ways to create a full volume of $$$m$$$ issues.
Since the answer might be very large, output it modulo $$$10^9 + 9$$$.
2 3 1 1 1 1
18
3 4 1 2 3 1 3 2
180
Let's denote issues about Meatio with lowercase English letters and issues about Meatigi with uppercase English letters. We will also use same letters to denote issues belonging to the same story arc and assign letters to arcs in alphabetic order. In this notion, following combinations are possible in the first example:
abc, abb, aab, ABC, ABB, AAB, abA, aaA, ABa, AAa, aAB, aAA, Aab, Aaa, aAb, aAa, AaB, AaA.
| Название |
|---|


