Standard Problem

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You are given nn segments \[l_i,r_i]\[l\_i,r\_i] (1l_ir_im1 \le l\_i \le r\_i \le m). Each segment has a weight c_ic\_i.

Let us choose a subsequence of segments, from each chosen segment choose an integer and arrange them in the same order as initial segments. By this operation we will get an integer sequence. We say that a subsequence of segments is good if we can construct a nondecreasing integer subsequence from it.

Let kk be the maximum weight of a good subsequence (the sum of weights of all segments in the subsequence). Calculate kk and the number of good subsequences of weight kk. Since the number of subsequences can be large, calculate it modulo 998,244,353998\\,244\\,353.

입력

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) --- the number of test cases. Description of test cases follows.

The first line of each test case contains two integers nn, mm (1n,m21051 \le n, m \le 2 \cdot 10^5).

Each of the next nn lines contains three integers l_il\_i, r_ir\_i, c_ic\_i (1l_ir_im1 \le l\_i \le r\_i \le m, 1c_i1091 \le c\_i \le 10^9) --- description of the ii-th segment.

It is guaranteed that both the sum of nn and the sum of mm for all test cases do not exceed 21052 \cdot 10^5.

출력

For each test case, print two integers --- the maximum weight of a good subsequence and the number of good subsequences with maximum weight (the second number modulo 998,244,353998\\,244\\,353).