Programming Club | 프로그래밍의 벗 PivotOJ
PivotOJ

Programming Club

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2018-19 prelimBOJ 29943

문제

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 lil_i, then attends every week until week rir_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 (1N1051 \le N \le 10^5) and number of club members KK (1K1051 \le K \le 10^5). Weeks are numbered 1N1 \ldots N. On each of the following KK lines are two space-separated integers: the first week lil_i and the last week rir_i when when the member ii attends (1liriN1 \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

입력
12 5
1 6
7 8
1 4
3 9
5 12
출력
1
2
3
4
5
6
1
2
7
3
4
8
코드를 제출하려면 로그인하세요.