Under construction

Still being built. Things may change

Four Elements

Time limit2sMemory limit512 MB

Summary
Count the 4-element subsets of a union of n disjoint integer ranges whose sum equals s, modulo 998244353.
Level

Hard9 of 10

Topics
Math, Combinatorics, Intervals, Dynamic programming
Solved
No attempts yet

Problem

Set AA is the union of nn ranges [li,ri][l_i, r_i]. How many 4-element subsets of AA have a sum equal to ss? Print the count modulo 998 244 353.

Input

The first line contains two integers nn and ss (1≤n≤4001 \le n \le 400, 0≤s≤8⋅1080 \le s \le 8 \cdot 10^8). Each of the next nn lines contains two integers lil_i and rir_i, the bounds of the ii-th range (0≤li≤ri≤2⋅1080 \le l_i \le r_i \le 2 \cdot 10^8, ri<li+1r_i < l_{i+1}).

Output

Print the number of 4-element subsets of AA with sum ss, modulo 998 244 353.

Hint

In the example, A={1,2,3,5,6,7,8}A = \{1, 2, 3, 5, 6, 7, 8\}. The 4-element subsets with sum 17 are {1,2,6,8}\{1, 2, 6, 8\}, {1,3,5,8}\{1, 3, 5, 8\}, {1,3,6,7}\{1, 3, 6, 7\}, and {2,3,5,7}\{2, 3, 5, 7\}.

Examples1

  1. Example 1

    Input
    2 17
    1 3
    5 8
    
    Expected output
    4