407061: GYM102697 032 Prison Break

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

032. Prison Breaktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Unfortunately, you have been sent to prison because you solved too many problems at CodeQuest 2021. Now, you're trying to break out. Your cell has a combination lock with $$$n$$$ dials. You're planning to try all of the possible combinations of the lock, and you want to know how many possible combinations the lock has.

Input

The first line of input contains a positive integer $$$n$$$: the number of dials on the lock. The next $$$n$$$ lines each contain two space-separated integers: the lower and upper limits of each lock dial. For example, if the lower and upper limits were $$$3$$$ and $$$7$$$, respectively, then the lock dial could turn to 3, 4, 5, 6, or 7.

Output

Output a single integer $$$c$$$: the total number of possible lock combinations.

ExamplesInput
4
2 10
3 9
11 16
5 8
Output
1512
Input
3
1 2
1 3
11 12
Output
12

加入题单

上一题 下一题 算法标签: