you got a job as an administrator in a small but very popular Cosmos hotel. The previous administrator kept records of guests in a notebook, and confusion constantly arose: the guests were settled in already occupied numbers or, conversely, the rooms were idle, although it would be possible to hand them over. The director set you the task & mdash; To automate the distribution process of guests by numbers.
rn
Your program must accept the list of applications for reservation and determine the room number for each application. The main goal & mdash; Use as few rooms as possible to reduce cleaning and maintenance costs. New rooms should be opened only in case of emergency. If several rooms are released, the guest should be populated into the room with the smallest number.
rn
formal condition:
you have a list of & nbsp; n & nbsp; customers. For each client, the day of his arrival and the day of departure are known. Days are numbered by integer. The guest occupies the number in the morning of the day of arrival and liberates it in the morning of the day of departure. This means that if one guest leaves on the day of X, then the other guest can already call on this room on the same day X.
rn
you need to write a program that for each client (in the order in which they were fed) will determine the room number in which he is in which he will be populated. The numbering of the rooms begins with 1. The algorithm should be “greedy”: always try to populate a new guest in the previously used room with a minimum possible number, and only if there are no free rooms & mdash; Open a new one.
rn
& nbsp;
Input format
& nbsp; n & nbsp; lines. Each line contains two numbers separated by a gap: & nbsp; day_ Recreation & nbsp; and & nbsp; day_nival (integers). These lines submit applications from customers and can be in random order.
rn
at the end there will be a line "end".
Output format
One line containing & nbsp; n & nbsp; numbers separated by a gap. & nbsp; i the number in the line & mdash; This is the room of the room allocated & nbsp; i -the client from the original list.
Example
Input
1 5
8 10
2 4
6 9
1 3
rn
end
Hint
There will be no clue here, decide for yourself!