Next Free Locker
A gym's front desk hands out lockers through a small kiosk. There are n lockers numbered 1 to n, and when the gym opens every locker is free.
Members do not always want the first free locker: someone whose friend is already inside may ask for "the third free one" to end up nearby. The kiosk therefore supports two commands:
TAKE k— find thek-th free locker in increasing order of locker number, mark it as taken and print its number. If fewer thanklockers are currently free, nothing changes and the kiosk prints-1.RELEASE i— a key is returned for lockeri, so lockeribecomes free. If lockeriis already free (a stray key, or one returned twice), nothing changes.
Process the commands in the given order.
Input
The first line contains two integers n and q (1 ≤ n ≤ 10^6, 1 ≤ q ≤ 5·10^5) — the number of lockers and the number of commands.
Each of the next q lines contains one command, either TAKE k (1 ≤ k ≤ n) or RELEASE i (1 ≤ i ≤ n).
Output
For every TAKE command, print one line with the number of the assigned locker, or -1 if fewer than k lockers are free. RELEASE commands produce no output.
Notes
In the first example, TAKE 2 assigns locker 2. The free lockers are then 1, 3, 4, 5, so TAKE 3 assigns locker 4. Now only 1, 3, 5 are free, so TAKE 4 prints -1. RELEASE 2 makes lockers 1, 2, 3, 5 free, and TAKE 2 assigns locker 2 again. RELEASE 3 is ignored because locker 3 is already free, so TAKE 3 sees the free lockers 1, 3, 5 and assigns locker 5. Finally TAKE 1 assigns locker 1.
In the second example there is a single locker, and a TAKE fails whenever it is occupied.