Akcija

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

문제

Christmas, a time for giving. Mr. Malnar is in need of gift ideas. Although deep in thought, the television program grabs his attention: “Special offer! This amazing product is on sale for just ww kunas. Call now because the offer is available only if you call within the next dd minutes. But that’s not all...”

There are nn different products on sale, where the ii-th product has a cost of w_iw\_i, and it’s available for order until the minute d_id\_i (inclusive). Making a call to place an order requires one minute. A subset of products is called obtainable if it is possible to make a sequence of calls which order those products while meeting the mentioned deadlines. No product can be ordered more than once.

Mr. Malnar intends to buy as many products as possible, at the least possible price, but he’s not yet sure which products he should buy. He compares two obtainable subsets in the following way: the better obtainable subset is the one with more products, and if they have equal size, it’s the one that has a smaller total cost (sum of costs of chosen products).

Mr. Malnar will rank the obtainable subsets in the described manner and he will take into consideration kk of the best ones. Write a program which determines the size and the total cost for kk of the best obtainable subsets.

입력

The first line contains positive integers nn and kk - the number of different products and the number of obtainable subsets to be taken into consideration, respectively. kk will be less than or equal to the total number of obtainable subsets.

The following nn lines contain two positive integers w_iw\_i (1w_i1091 ≤ w\_i ≤ 10^9) and d_id\_i (1d_in1 ≤ d\_i ≤ n) - the cost of the ii-th product and the last minute for which the offers stands, respectively.

출력

In the i-th line print the size and the total cost of the i-th best obtainable subset.

제한

In every subtask, it holds that 1n,k20001 ≤ n, k ≤ 2000.

힌트

Clarification of the second example: Products 1 and 2 can’t simultaneously be in an obtainable subset, so the three best obtainable subsets are {1, 3, 4}, {2, 3, 4} and {1, 3}.