The Princess Waraku show Izuna is helping with today is an interactive event! Izuna, an audience member, becomes the hero, overcomes obstacles in the film village, and rescues the kidnapped princess!
It is supposed to be a participatory performance where we save the princess... But instead of Princess Waraku, Ibuki, who has nothing to do with the show, has been kidnapped?!
|
Michiru |
All right, then! The goal is simple! |
|
Michiru |
We, the Ninjutsu Research Club, will rescue Ibuki before things get serious! Got it?! |
|
Izuna |
Yes! If someone is in danger, a ninja comes to their rescue! Nin-nin! |
|
Tsukuyo |
Ibuki... She must be crying from fear! We have to save her! Together! |
|
Iroha |
...Ibuki, please wait for us. We'll be there soon. |
Izuna followed the kidnappers' escape route with the Ninjutsu Research Club, and we arrived at the Trick House!
|
Kaede |
Hi there~! Welcome, everyone! Your next challenge is the Trick House! |
|
Kaede |
Packed with all kinds of traps and contraptions...! It's the most famous attraction in the Uzumaki Film Village! |
|
Michiru |
Isn't that... just a ninja mansion? |
|
Kaede |
Anyway~! Passing this challenge is simple! Make your way through this mansion... |
|
Kaede |
Overcome the trials inside and reach the finish, and you pass! That's how it works! |
|
Izuna |
President! For a Trick House, Izuna thinks it is important to discuss our strategy beforehand...! |
The president went in ahead of us just like that, and Izuna ended up wandering around the Trick House for quite a while... But now, at last, we are all together again!
|
Michiru |
...Huh? You're all safe? |
|
Izuna |
Izuna got so lost, I thought I would never get out...! And then! Tsukuyo-dono figured out what to do! |
|
Tsukuyo |
I-I remembered... seeing this mansion in the manga you lent me, P-President... |
|
Tsukuyo |
I-I'm glad I read it when you recommended it! Ehehe! |
Tsukuyo-dono's solution was simple! If we think of movement inside the Trick House mansion as movement on a grid, we can make a plan without getting lost...! So Izuna decided to model it as follows!
We can think of the Trick House mansion as an isosceles right triangle whose equal sides have length ! Mathematically... speaking, its two equal sides lie along the positive -axis and the positive -axis of the coordinate plane. Its vertices are therefore , , and !
Figure 1. The Trick House mansion for
Izuna moves from the starting point at the upper-left vertex to the finish at the lower-right vertex . On each move, Izuna does one of the following!
The first line contains and , separated by a space. ; ;
Print the number of paths satisfying all the conditions on the first line. Since this number may be very large, output it modulo .
Michiru
|
It's fine, it's fine. Just keep going and we'll work it out! |
|
Kaede |
Ah! I haven't finished explaining yet! |
The inside of the mansion forms a grid. As in the drawing Izuna made below, row from the top contains square cells in columns through , and an isosceles right triangular cell in column ! Every side of a cell has length , except for the hypotenuses of the triangular cells!
Then... we only consider paths with exactly moves! And since Izuna must not leave the mansion, Izuna must always remain inside the triangle, including its boundary, throughout the journey.
But the mansion is full of terrifying traps! According to the information Izuna gathered, all of the following conditions must be met during the journey!
In other words, move must be a dodge (→), and it must be the -th dodge (→) in the entire path! Of course, Izuna is a ninja, so Izuna can dodge (→) even when there is no trap!
There are many branching routes to the finish, so it is important to know all routes that satisfy the conditions! Let us find how many paths Izuna can choose! Nin-nin!
Each of the next lines contains and , separated by a space. ; ; ;