Naruto's signature jutsu is the shadow clone jutsu. He can create over 200000 clones of himself!
On a line, Naruto has created copies of himself. He has numbered each of his clones from to . His clone, located at position , will begin walking with a velocity of towards the positive direction at time .
As Sasuke and Naruto are such great rivals, Sasuke has mastered a... new type of jutsu. At time , he can choose a number of shadow clones, and that clone will turn into a clone of Sasuke! When the clone turns into Sasuke, the velocity and position of the clone will not change, and it will continue walking towards the positive direction. Furthermore, once a Sasuke clone touches another Naruto clone, the Naruto clone will become a Sasuke clone!
There are many clones Sasuke could choose at time to transform all of the Naruto clones to Sasuke clones. How many ways will all of Naruto's clones turn into Sasuke clones after an infinitely large amount of time?
Constraints
- , such that
- All values of will be distinct, and so will .
Input Specification
The first line of input will contain an integer .
The next lines of input will contain 2 space separated integers, and .
Output Specification
You are to output a single integer, the number of ways at time to change a number of Naruto clones to Sasuke clones, modulo .
Sample Input 1
3
2 5
6 1
3 7
Sample Output 1
6
Sample Explanation
After an infinitely large amount of time, the ways Sasuke could choose clones at time are:
, , , , , .
Comments