#P9400. 「DBOI」Round 1 三班不一般

「DBOI」Round 1 三班不一般

Background

HQ is a diligent logistics teacher at the legendary good-looking high school, and also a member of the dormitory management team, responsible for managing switching the lights on and off.

For him, the most annoying thing is that a group of “monkeys” from the very unusual Class 3 mess around with the lights in their own dorms and other dorms, yet he cannot catch and arrest the culprit on the spot.

Problem Description

HQ needs to manage the lights of nn dormitories. Students in dormitory ii are very picky because of their legendary good looks, and they can only tolerate lights with brightness in [li,ri][l_i,r_i]. The brightness of each dormitory’s light can be adjusted freely within its tolerable range.

Today, Chen Tianrun decided to become the commander-in-chief and adjust the lights of all dormitories. To avoid being caught by HQ on the spot, he cannot let HQ notice that the dormitory lights are too dazzling. When the brightness of the lights in aa consecutive dormitories are all greater than bb, the dormitory lights become dazzling. No, commander-in-chief.\color{white}\text{No, commander-in-chief.}

Therefore, help Chen Tianrun count how many light-bulb adjustment plans can ensure the dormitories are not dazzling. Output the answer modulo 998244353998244353.

Input Format

The first line contains three positive integers n,a,bn,a,b, with meanings as described in the statement.

Then there are nn lines. Each line contains two positive integers. The two integers on line ii are li,ril_i,r_i, respectively.

Output Format

Output one integer on a single line, the answer modulo 998244353998244353.

3 1 3
3 4
3 3
2 4
2
5 2 5
2 4
1 6
5 10
1 1
5 6
186
12 9 66
41 76
33 61
10 25
84 86
20 49
43 59
26 56
44 71
48 79
1 35
27 83
49 76
358014651

Hint

Sample Explanation

For sample 11, there are only two valid plans: {3,3,2}\{3,3,2\} or {3,3,3}\{3,3,3\}.

For sample 33, please output the answer modulo 998244353998244353.

Constraints

This problem uses bundled testdata.

For all testdata, 1n21051\le n\le 2\cdot 10^5, 1an+11\le a\le n+1, 1b1091\le b\le 10^9, 1liri1091\le l_i\le r_i\le 10^9.

Subtask\textrm{Subtask} n,(a1)n,(a-1)\le li,ri,bl_i,r_i,b\le Special Property Score
11 55 2020 None 1010
22 21052\cdot 10^5 10910^9 a=n+1a=n+1
33 a=1a=1
44 10310^3 None 3030
55 21052\cdot 10^5 4040

Translated by ChatGPT 5