#1049
Unrated
FUNKCIJA
시간 제한
1s
메모리 제한
128MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Goran Gašić

Mirko has written the following function:

int fun() { int ret = 0; for (int a = X1; a <= Y1; ++a) for (int b = X2; b <= Y2; ++b) ... for (int = XN; <= YN; ++) ret = (ret + 1) % 1000000007; return ret; }

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 := XN to YN do ret := (ret + 1) mod 1000000007; fun := ret; end; denotes the Nth lowercase letter of the English alphabet. Each Xi and Yi denotes either a positive integer less than or equal to 100 000 or a name of a variable that some outer loop iterates over. For example, X3 can be either a, b, or an integer literal. At least one of Xi and Yi will be an integer literal (i.e. not a variable name) for every i. Compute the return value of the function.

입력

The first line of input contains the positive integer N (1 ≤ N ≤ 26). For the next N lines, the ith line contains Xi and Yi, separated with a space. If Xi and Yi are both integer literals, then Xi ≤ Yi.

출력

The first and only line of output must contain the return value of the function.

예제 입력 1

2
1 2
a 3

예제 출력 1

5

예제 입력 2

3
2 3
1 2
1 a

예제 출력 2

10

예제 입력 3

3
1 2
a 3
1 b

예제 출력 3

11
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.