PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000070. Kỳ nghỉ hè (Summer Vacation)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kỳ nghỉ hè (Summer Vacation)

Summer Vacation

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN one-time jobs. If job ii is performed on a day, it pays reward BiB_i exactly AiA_i days later. You may start today, perform at most one job per day, and cannot repeat jobs. Maximize the rewards received no later than MM days from today.

Input

The first line contains N,MN,M. Each of the next NN lines contains Ai,BiA_i,B_i.

Output

Print the maximum reward received by the deadline.

Subtasks

  • Subtask 1 (20 points): 1≤N≤241\le N\le 24; 1≤M≤1051\le M\le10^5; 1≤Ai≤1051\le A_i\le10^5, 1≤Bi≤1041\le B_i\le10^4 for all ii.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000; 1≤M≤1051\le M\le10^5; 1≤Ai≤1051\le A_i\le10^5, 1≤Bi≤1041\le B_i\le10^4 for all ii.
  • Subtask 3 (50 points): 1≤N≤1000001\le N\le 100000; 1≤M≤1051\le M\le10^5; 1≤Ai≤1051\le A_i\le10^5, 1≤Bi≤1041\le B_i\le10^4 for all ii.

Examples

Input

3 4
4 3
4 1
2 2

Output

5

Explanation

Do job 11 today for reward 33 received after 44 days, then job 33 tomorrow for reward 22 received three days from today. Both pay within the 44-day deadline, giving total reward 55.