题目描述
Problem Description
Mirko has written the following function:
(C++)
int fun() {
int ret = 0;
for (int a = X1; a <= Y1; ++a)
for (int b = X2; b <= Y2; ++b)
...
for (int <N-th> = XN; <N-th> <= YN; ++<N-th>)
ret = (ret + 1) % 1000000007;
return ret;
}
(Pascal)
function fun: longint;
var
ret: longint;
a, b, ... , y, z: longint;
begin
ret := 0;
for a := X1 to Y1 do
for b := X2 to Y2 do
...
for <N-th> := XN to YN do
ret := (ret + 1) mod 1000000007;
fun := ret;
end;
<N-th> represents the $N$-th lowercase letter. Each $X_i$ and $Y_i$ may represent a variable name from an outer loop or a positive integer $\le 10^5$. For example, $X_3$ could be $a$, $b$, or an integer constant. At least one of $X_i$ and $Y_i$ will be an integer constant.
Calculate the return value of this function.
Input Format
The first line of input contains a positive integer $N$.
The next $N$ lines, the $i$-th line contains two space-separated values $X_i, Y_i$. If both $X_i$ and $Y_i$ are integer constants, then $X_i \le Y_i$.
Output Format
Output a single integer, which is the return value of the function.
Sample Input and Output
Sample Input #1
2
1 2
a 3
Sample Output #1
5
Sample Input #2
3
2 3
1 2
1 a
Sample Output #2
10
Sample Input #3
3
1 2
a 3
1 b
Sample Output #3
11
Notes
Data Range
For $100\%$ of the data, $1 \le N \le 26$.
Notes
This problem is scored according to the original COCI settings, with a maximum score of $150$.
The problem is translated from COCI2011-2012 CONTEST #2 T5 FUNKCIJA.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分