Festival

아직 제출이 없습니다메모리 제한1024 MB

문제

You have just heard about a wonderful festival that will last for DD days, numbered from 11 to DD. There will be NN attractions at the festival. The ii-th attraction has a happiness rating of h_ih\_i and will be available from day s_is\_i until day e_ie\_i, inclusive.

You plan to choose one of the days to attend the festival. On that day, you will choose up to KK attractions to ride. Your total happiness will be the sum of happiness ratings of the attractions you chose to ride.

What is the maximum total happiness you could achieve?

입력

The first line of the input gives the number of test cases, TTTT test cases follow.

The first line of each test case contains the three integers, DDNN and KK. The next NN lines describe the attractions. The ii-th line contains hihi, s_is\_i and e_ie\_i.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum total happiness you could achieve.

제한

  • 1T1001 \le T \le 100.
  • 1KN1 \le K \le N.
  • 1s_ie_iD1 \le s\_i \le e\_i \le D, for all ii.
  • 1h_i3×1051 \le h\_i \le 3 \times 10^5, for all ii.

힌트

In sample test case 1, the festival lasts D=10D=10 days, there are N=4N=4 attractions, and you can ride up to K=2K=2 attractions.

If you choose to attend the festival on the 6th day, you could ride the first and second attractions for a total happiness of 800+1500=2300800+1500=2300. Note that you cannot also ride the third attraction, since you may only ride up to K=2K=2 attractions. This is the maximum total happiness you could achieve, so the answer is 23002300.

In sample test case 2, the festival lasts D=5D=5 days, there are N=3N=3 attractions, and you can ride up to K=3K=3 attractions.

If you choose to attend the festival on the 3rd day, you could ride the first and third attractions for a total happiness of 400+300=700400+300=700. This is the maximum total happiness you could achieve, so the answer is 700700.