#SGM0000028. Khách sạn (Hotel)
Khách sạn (Hotel)
Hotel
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
A hotel has consecutive rooms numbered through , initially all empty. Process requests:
1 D: a group needs exactly consecutive rooms. If possible, choose the free block with the smallest starting index, print that start, and mark all rooms occupied. If no block exists, print0.2 X D: vacate rooms . Some of them may already be empty.
Input
The first line contains .
The next lines contain the requests.
Output
For every type 1 request, print the selected starting room or 0.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , , , and every checkout range lies inside .
Examples
Input
10 6
1 3
1 3
1 3
1 3
2 5 5
1 6
Output
1
4
7
0
5
Explanation
The sample is processed in order; every printed item/line corresponds to an operation that requires output.