P18106 [COCI 2026/2027 #2] Jackpot
Description
Ivor is a special kind of programmer, but others fail to understand his genius. Most people consider his programs messy because Ivor hates the Enter key more than anything else. This has become unbearable for his friends Dino and Niko, who already have trouble reading, let alone reading his messy code. Therefore, they have decided to force him to use the Enter key.
Ivor’s keyboard has $n$ characters, numbered from $1$ to $n$, but Niko and Dino have connected each character to the Enter key. Each time Ivor presses the Enter key, **at most one character** is added to his code: character $i$ is added with probability $a_i/b_i$, and with the remaining probability, no character is added. The presses are mutually independent.
Ivor will be forced to press the Enter key until he achieves a **jackpot**, which occurs when every character $i$ appears in his code at least $k_i$ times. Ivor is interested in the **expected number of Enter key presses** required to achieve the jackpot. Since Ivor cannot write a program himself to answer this question, he needs your help.
**Note: Pay attention to the unusual memory limit.**
Input Format
The first line contains a positive integer $n$ ($1 \le n \le 100\,000$), the number of characters on the keyboard.
The second line contains $n$ integers $k_1, k_2, \ldots, k_n$ ($k_i \ge 0$, $1 \le k_1+k_2+\cdots+k_n \le 22$).
The third line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 10^9$).
The fourth line contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$, $a_i \le b_i$).
The sum of all probabilities $a_i/b_i$ is not greater than $1$. If the jackpot is achievable, then for every non-empty set of characters for which $k_i > 0$ the numerator of the reduced fraction representing the sum of their probabilities is not divisible by $10^9+7$.
Output Format
If the jackpot is not achievable, output the word `nikada` in a single line.
Otherwise, it can be shown that the required answer is a fraction $P/Q$, where $P$ and $Q$ are positive integers and $Q$ is not divisible by $10^9+7$. In a single line, output the value of $P \cdot Q^{-1}$ modulo $10^9+7$, where $Q^{-1}$ is the modular multiplicative inverse of $Q$.
Explanation/Hint
### Explanation of example 1
With each press of the Enter key, the only character is added to the code with probability $1/6$, and it is sufficient to add it just once to achieve the jackpot. Therefore, the expected number of presses is $6$.
### Explanation of example 2
With the first press of the Enter key, one of the two characters is guaranteed to be added. After that, the remaining character is added with probability $1/2$ on each press, so an expected $2$ additional presses are needed to add it. Therefore, the expected number of presses is $1+2=3$.
### Explanation of example 3
The probability of adding the only character to the code is $0$, but it must be added at least once to achieve the jackpot. Therefore, the jackpot is impossible to achieve.
### Scoring
| Subtask | Points | Constraints |
| --- | ---: | --- |
| 1 | 9 | $n=1$ |
| 2 | 26 | $k_1+k_2+\cdots+k_n \le 2$ |
| 3 | 39 | $k_1+k_2+\cdots+k_n \le 16$ |
| 4 | 31 | $k_i \le 1$ for each $i=1,2,\ldots,n$. |
| 5 | 5 | No additional constraints. |