n, k = map(int, input().split())
free_seats = list(range(1, n + 1))
occupied_seats = []
for _ in range(k):
    query = input().strip()
    if query == "+":
        seat_to_allocate = free_seats.pop()
        occupied_seats.append(seat_to_allocate)
        print(seat_to_allocate)
    else:
        passenger_left = int(query)
        free_seats.append(passenger_left)
        occupied_seats.remove(passenger_left)
        free_seats.sort(reverse=True)

