Trains
문제
You have arrived in Vilnius and want to visit various cities in Lithuania.
Cities in Lithuania are located on a straight line and numbered from to sequentially. Vilnius is assigned the number .
Each city has a train station with a single train route that operates from that station. You can only get on a train at the start of its route, though you can get off at any of its stops. Trains starting their route at the -th city make a stop every cities, and their route consists of stops (not including the starting city). If , the trains operating from the -th city are currently out of service, so you cannot get on them.
To be more precise, if you get on a train in the -th city, you can get off the train in any city numbered , where 1 ≤ t ≤ x_i. Note that since you only want to visit cities in Lithuania, you won't ride further than the -th city, even if the train has more stops on its route.
You are going to visit some cities, using trains to travel between them. As you plan your trip, you start to wonder how many different options you have for your journey that starts at Vilnius. Two journeys are different if they make stops at different sequences of cities.
Calculate this number and print the answer modulo .
입력
The first line contains one integer – the number of cities.
Then lines follow. The -th of them contains two integers and – the numbers describing the route starting in the -th city.
출력
Output a single integer – the number of ways you can visit some of the cities taken modulo .
예제
예제 1
5 1 3 2 1 1 3 0 10 3 5
7