from collections import deque

n, k = map(int, input().split())
available_seats = deque(range(1, n + 1))
occupied_seats = set()

for _ in range(k):
    query = input().strip()
    if query == '+':
        if available_seats:
            seat = available_seats.pop()
            occupied_seats.add(seat)
            print(seat)
        else:
            print(-1)  # Нет свободных мест
    else:
        passenger = int(query[1:])
        occupied_seats.remove(passenger)
        available_seats.appendleft(passenger)
