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

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

Programming Club

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

요약
매주 참석하는 회원 구간이 주어질 때, 각 주에 아직 풀리지 않은 가장 작은 문제 번호를 출력한다.
난이도

보통10점 중 7점

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

문제

School's programming club meets once a week and solves one problem every week. Problems are taken from a very thick and important book where they have been numbered starting from 11 and where there's an infinite number of problems. Every week the club members attending take the book, find the problem with the smallest number that none of them has solved yet, and solve it.

The club, however, has a problem with retaining its members. Each member ii starts attending on some week l_il\_i, then attends every week until week r_ir\_i, but never comes back after that.

Determine which problem is solved every week.

입력

On the first line of input are two space-separated integers: number of weeks NN (1≤N≤1051 \le N \le 10^5) and number of club members KK (1≤K≤1051 \le K \le 10^5). Weeks are numbered 1…N1 \ldots N. On each of the following KK lines are two space-separated integers: the first week l_il\_i and the last week r_ir\_i when when the member ii attends (1≤l_i≤r_i≤N1 \le l\_i \le r\_i \le N). You can assume that every week at least one member attends the club.

출력

Write NN lines into output: the number of the problem solved during week jj onto line jj.

예제1

  1. 예제 1

    입력
    12 5
    1 6
    7 8
    1 4
    3 9
    5 12
    
    예상 출력
    1
    2
    3
    4
    5
    6
    1
    2
    7
    3
    4
    8