문제
Bessie has been given
Define the union of a set of segments to be the set of all
Bessie wants to compute the sum of the complexities over all
Normally, your job is to help Bessie. But this time, you are Bessie, and there is no one to help you. Help yourself!
SCORING
Test case 2 satisfies
N\le 16 .Test cases 3-5 satisfy
N\le 1000 ,K=2 .Test cases 6-8 satisfy
N\le 1000 .For each
T\in [9,16], test caseT satisfiesK=3+(T-9) .
입력
The first line contains
Each of the next
It is guaranteed that
출력
Output the answer, modulo
예제1
3 2
1 6
2 3
4 5
10
The complexity of each nonempty subset is written below.
The answer is