from collections import deque


def solve_dispenser():
    liters = int(input())
    people = deque()
    while True:
        person = input()
        if person == "Start":
            break
        people.append(person)

    while people:
        command = input()
        if command.startswith('refill'):
            liters += int(command.split()[1])
            continue
        person = people.popleft()
        person_litters = int(command)
        if liters < person_litters:
            print(f"{person} must wait")
        else:
            liters -= person_litters
            print(f"{person} got water")

    print(f"{liters} liters left")


solve_dispenser()


# Test input
# 10
# Peter
# George
# Amy
# Alice
# Start
# 2
# 3
# 3
# 3
# End