아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Hasty Santa Claus

시간 제한2초메모리 제한1024 MB

요약
각 집의 방문 가능 구간 [a_i, b_i] 안에서 하루에 최대 k채만 방문하도록 모든 집의 방문 날짜를 정한다.
난이도

보통10점 중 6점

유형
그리디, 구간, 정렬
정답자
아직 제출이 없습니다

문제

Hasty Santa Claus has arrived at the town on December 1st. Realizing that it is a little bit too early for Christmas, he plans to leave the presents before (or even after) Christmas while families are out on vacation trips.

Santa knows which families depart and return on which days, but he can visit only a limited number of houses a day. He is stuck with finding which houses are to be visited on which days to distribute the presents to every family. Please help him solving the problem, not only for Santa but also for kids anxiously awaiting for the presents!

입력

The input consists of a single test case of the following format.

nn kk

a_1a\_1 b_1b\_1

⋮\vdots

a_na\_n b_nb\_n

The first line has two positive integers, nn and kk, the number of houses to leave the presents and the maximum number of houses that Santa Claus can visit a day, respectively.

The ii-th line of the following nn lines has two positive integers a_ia\_i and b_ib\_i. They indicate that he can visit the ii-th house between the a_ia\_i-th and b_ib\_i-th days, inclusive.

nn and kk satisfy 1≤k≤n≤10001 ≤ k ≤ n ≤ 1000. For each ii, a_ia\_i and b_ib\_i satisfy 1≤a_i≤25≤b_i≤311 ≤ a\_i ≤ 25 ≤ b\_i ≤ 31.

출력

Print nn lines of one integer describing a plan for Santa to complete his task. The integer on the i-th line means the date on which Santa should visit the ii-th house.

At least one solution is guaranteed to exist. If there are two or more solutions, any of them is accepted.

힌트

The first sample is depicted in the figure below. Santa can leave the presents during the periods shown as horizontal lines with short vertical markers at both ends. For the House 4, Santa can visit only on a specific day. The triangles show the days on which Santa should visit each house.

Figure A.1. Sample 1

예제3

  1. 예제 1

    입력
    5 1
    23 25
    23 27
    24 25
    25 25
    25 26
    
    예상 출력
    23
    27
    24
    25
    26
    
  2. 예제 2

    입력
    7 2
    1 31
    1 31
    1 31
    1 31
    1 31
    1 31
    1 31
    
    예상 출력
    1
    1
    2
    2
    3
    3
    4
    
  3. 예제 3

    입력
    6 2
    24 25
    24 25
    24 25
    25 26
    25 26
    25 26
    
    예상 출력
    24
    25
    24
    26
    25
    26