{"raw_statement":[{"iden":"problem statement","content":"There are $N$ continuous random variables $x_i$ ($1 ≤ i ≤ N$), each of which follows the continuous uniform distribution on the interval $[L_i, R_i]$. (That is, $x_i$ is a random variable that can take any real value between $L_i$ and $R_i$ (inclusive) with equal probability.)\nLet $E$ be the expected value of the maximum of these $N$ random variables. Under the constraints in this problem, it can be proved that $E \\times (N+1)! \\times \\prod_{i=1}^N (R_i - L_i)$ is a positive integer. Find this value modulo $1,000,000,007$."},{"iden":"constraints","content":"*   $1 ≤ N ≤ 1000$\n*   $0 ≤ L_i < R_i ≤ 10^9$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$L_1$ $R_1$\n$:$\n$L_N$ $R_N$"},{"iden":"sample input 1","content":"1\n1 2"},{"iden":"sample output 1","content":"3\n\nThe expected value of the maximum of these random variables - there is actually just one in this case - is equal to the median of the range of the values the variable can take, that is, $E = \\frac{3}{2}$.\nThus, the correct output is $E \\times (N+1)! \\times (R_1 - L_1) = E \\times 2 = 3$."},{"iden":"sample input 2","content":"2\n1 2\n1 2"},{"iden":"sample output 2","content":"10\n\nThe expected value in question is $E = \\frac{5}{3}$."},{"iden":"sample input 3","content":"2\n1 2\n2 4"},{"iden":"sample output 3","content":"36"},{"iden":"sample input 4","content":"5\n40 96\n81 92\n16 384\n32 768\n65 536"},{"iden":"sample output 4","content":"52776507"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}