Penny spends too much time every day binge watching her favourite TV series! In order to get out of her addiction, she decided to be more disciplined and devote no more than minutes every day to her favourite activity.
To get the most out of the time that she has, Penny made a list of the next shows that she wants to watch, in order. Every TV series is composed of episodes each with a length of minutes (where ). Penny will never start a TV series before finishing to watch the previous one; and will never start an episode in a day if she does not have enough time left to finish it. How many days Penny needs to watch all the TV series she has planned so far? How many minutes will Penny spare in the last day, that could be used to start watching a new TV series?
Input data
The first line contains the two integers and . The following lines contain each two integers and .
Output data
You need to write a single line with two integers and : the number of days needed to watch all the shows, and the number of minutes spared in the last day.
Constraints and Clarifications
- ;
- ;
- for each ;
- for each .
# | Score | Restrictions |
---|---|---|
1 | 0 | Examples. |
2 | 10 | for each . |
3 | 20 | . |
4 | 30 | for each . |
5 | 40 | No additional limitations. |
Example 1
stdin
60 4
4 60
3 6
5 42
2 15
stdout
10 45
Explanation
Penny wants to spend an hour every day on TV series. Her first 4 days are spent watching the episodes of the first series. She can then watch the whole second series on the 5th day, using a total of minutes. With the remaining minutes she can already start the first episode of the third series on the 5th day, watching the following ones on days 6, 7, 8 and 9.
Notice that during days 6, 7 and 8, several minutes are left that cannot be used, since Penny does not want to start a new series before finishing the previous one. Part of the minutes left on the 9th day can however be used to start the last TV series. Her plan ends on the 10th day, with the only remaining episode of minutes. The other minutes are spare and usable for future shows.
Example 2
stdin
30 5
1000000000 30
1000000000 30
1000000000 30
1000000000 30
1000000000 30
stdout
5000000000 0
Explanation
Penny only wants to spend half an hour every day, forcing her to spend 5 billion days to end all the five TV series.