Random Addition
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Daniel and sszcdjr are playing a game. The game is played on a sequence a of length n. Initially, all elements in a are equal to 0. They will do the following operations m times on it:

* Daniel selects one segment [l_i,r_i] (1\le l\le r\le n);
* Then, sszcdjr chooses a real number x such that 0\le x\le 1 \bf{uniformly at random};
* For all l_i\le j\le r_i, set a_j:=a_j+x.

However, sszcdjr thinks it is unfair for him. So he adds a rule: for any two segments [l_i,r_i] and [l_j,r_j] (i\ne j), one of the following condition must holds:

* The two segments are completely disjoint. More formally, either l_i\le r_i<l_j\le r_j or l_j\le r_j<l_i\le r_i;
* One of the two segments are inside another. More formally, either l_i\le l_j\le r_j\le r_i or l_j\le l_i\le r_i\le r_j.

Note that two segments can be exactly the same.

Let s be the maximum number in a after the operations. zxx is crazy about probabilities, so he gives you t queries. In each query, he gives you two numbers P, Q, and asks you the probability that P\le s\le Q. You just need to tell him the answer modulo 998~244~353.

输入描述:

The first line of input contains three integers n, m, t (1\leq n\leq 10^6, 1\leq m \leq 200 1\leq t\leq 5\times 10^5) --- the length of the sequence, the number of operations and the number of queries.

Then m lines follow, the i-th line contains two integers l_i, r_i (1\le l_i\le r_i\le n) --- the segment in the i-th operation.

In the following t lines, each line contains two integers p, q (0\le p<q\le 10^7) --- the two numbers piggy give you in the query are equal to P=p\cdot 10^{-6} and Q=q\cdot 10^{-6} .

输出描述:

For each query print an integer --- the probability that P\le s\le Q, modulo 998~244~353. 

Formally, let M = 998\,244\,353. It can be shown that the answer can be expressed as an irreducible fraction \frac{p}{q}, where p and q are integers and q \not \equiv 0 \pmod{M}. Output the integer equal to p \cdot q^{-1} \bmod M. In other words, output such an integer x that 0 \le x < M and x \cdot q \equiv p \pmod{M}.
示例1

输入

复制
6 3 5
1 6
2 3
4 5
0 1000000
1000000 2000000
200000 800000
0 1500000
114 514

输出

复制
332748118
665496236
143747187
540715692
586651392