This page is still under construction.

Parts of this page are still being built. What you see may change.

Interval

Time limit4sMemory limit512 MB

Summary
Given n intervals and m queries [A,B], find the expected union length of intervals over a uniformly random sub-range [L,R] within [A,B], modulo 998244353.
Level

Hard9 of 10

Topics
Divide and conquer, Segment tree, Combinatorics, Intervals
Solved
No attempts yet

Statement

You are given nn intervals, the jj-th of which is Ij=[lj,rj]I_j = [l_j, r_j].

The beauty of [L,R][L, R] is the length covered by ⋃i=LR[li,ri]\bigcup_{i = L}^{R} [l_i, r_i].

You are given mm queries. The ii-th query is [Ai,Bi][A_i, B_i], and you need to answer the following.

Choose [Li,Ri][L_i, R_i] uniformly at random from all integer pairs with Ai≤Li≤Ri≤BiA_i \le L_i \le R_i \le B_i. Find the expected beauty of [Li,Ri][L_i, R_i].

The expected value can be written as a fraction p/qp/q with coprime non-negative integers pp and qq. Print p⋅q−1 mod 998 244 353p \cdot q^{-1} \bmod 998\,244\,353.

Input

The first line contains two integers nn and mm (1≤n,m≤2⋅1051 \le n, m \le 2 \cdot 10^5).

Each of the next nn lines contains ljl_j and rjr_j (0≤lj<rj≤1080 \le l_j < r_j \le 10^8).

Each of the next mm lines contains AiA_i and BiB_i (1≤Ai≤Bi≤n1 \le A_i \le B_i \le n).

Output

Print mm lines. Line ii contains the answer for the ii-th query, taken modulo 998 244 353998\,244\,353.

Hint

The input and output are large, so use fast I/O to avoid exceeding the time limit.

Examples1

  1. Example 1

    Input
    2 1
    1 5
    4 8
    1 2
    
    Expected output
    5