Shirogane and Fujiwara are practicing a song together. Fujiwara has written down the pitches of the song in order. They are given as a sequence of nonnegative integers of length , where the -th note has pitch .
Let the pitches actually sung by Shirogane be a sequence of nonnegative integers . The first pitch must be . However, Shirogane cannot change the pitch too much between consecutive notes. Therefore, for every , the following condition must hold:
Define the error on the -th note as . The total error of the whole song is
This total error must be at most .
Find the number of integer sequences satisfying all conditions. Since the answer can be very large, print it modulo .
The input is given from Standard Input in the following format:
Print the number of integer sequences satisfying all conditions, modulo .
The five valid sequences are , , , , and .
| 3 | 74 | No additional constraints. |
Since and , only is possible. Its total error is , so it satisfies all conditions.
Since and , we have . Thus, the total error is at least , so there is no valid sequence.