For a number sequence

of length

and a bracket sequence

of

, denote that
![f(a,s)=\sum\limits_{i=1}^{2n}a_i[s_i],](https://www.nowcoder.com/equation?tex=f(a%2Cs)%3D%5Csum%5Climits_%7Bi%3D1%7D%5E%7B2n%7Da_i%5Bs_i%5D%2C)
where
Randias is facing a
too easy problem:
-
Given a number sequence
of length
, find the value of
where
is a regular bracket sequence of
.
For example,
%3Df(%5C%7B1%2C2%2C1%2C2%5C%7D)
,"(())"
%3D3)
and
%3Df(%5C%7B1%2C2%2C3%2C4%5C%7D)
,"()()"
%3D4)
,
Since this problem is too easy for Randias, so he's thinking of another
easy problem:
-
For each
,
,
,
,
is a uniformly random real number picked from
, find the expected value of
.
He wants you to find the answer of the easy problem and output it modulo

.
A bracket sequence is called regular if it is possible to obtain a correct arithmetic expression by inserting characters '+' and '1' into it. For example, sequences "(())()", "()", and "(()(()))" are regular, while ")(", "(()", and "(()))(" are not.
输入描述:
The first line contains one integer
(
), representing the half of the length of the sequence.
The following
lines, each of them contain two integers
(
), representing the interval where
is picked from.
输出描述:
One single integer, representing the answer, modulo
.
More precisely, assume the reduced fraction of the answer is
, you should output the minimum non-negative integer
such that
. You may safely assume that such
always exists in all test cases.
示例3
输入
复制
3
1 5
2 9
4 5
5 10
1 7
0 8
备注:
For the first example, note that the only regular bracket is "()", so the answer is the expected value of
, which is
.
For the second example, we can choose from "(())" or "()()", which means the answer is the expected value of
, one can prove that it equals to
.