Groundhog and Gaming Time
题号:NC208869
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

At the night of PKUWC2019day2, classmates (including Soetdit, TX1145967673, ZPAYAUR ,Groundhog and so on) made an amazing decision: they were ready to join together in a convoy, and they would share the night until dawn.

That night, they went online one after another. The i-th classmate will be online from .But someone reported a message: Their teacher will come at night. Everyone has a probability of  to receive the message, and one who receives the message will not go online at night. And their available time for game is when all gamers are online.So they begin to think about a question: What's expectation of the square of their available time modulo  ?

Simplified question:there are  segments , each segment has the possiblity of  to be selected, and the question is to calculate the expected value of  modulo a_i means the number of  selected segment.

输入描述:

The first line contains an integer  , denoting the number of students.
The next  lines each contains two integers L_i, R_i , which means the  student's gaming time.

输出描述:

Output one line contains the answer modulo .
示例1

输入

复制
6
2 2
1 2
1 4
1 5
3 5
3 6

输出

复制
405536771

备注:

.