#K79247. Elevator Simulation

    ID: 35266 Type: Default 1000ms 256MiB

Elevator Simulation

Elevator Simulation

You are given an elevator simulation problem. The building has \(F\) floors (numbered from 0 to \(F-1\)). Initially, the elevator is at the ground floor (floor 0). There are two types of commands:

  • call x: A passenger on floor \(x\) calls the elevator.
  • select x: A passenger inside the elevator selects the destination floor \(x\).

When a command is issued, the corresponding request is added to the elevator's queue. The elevator processes the queued requests one by one in the order they are received by moving to the specified floor, if the floor is valid (i.e. in the range \(0 \le x < F\)). If a request is invalid, the elevator ignores it and remains on its current floor. After processing each command, the elevator outputs its current floor. If there are no commands, simply output the initial floor.

inputFormat

The first line contains an integer \(F\) (the total number of floors). The second line contains an integer \(N\) (the number of commands). Each of the following \(N\) lines contains a command with a string and an integer separated by a space. The command is either "call" or "select", followed by the floor number \(x\).

Note: The elevator starts at floor 0. If \(N\) equals 0, output the initial floor (i.e. 0).

outputFormat

For each command processed, output a line containing the current floor of the elevator after processing that command. In the case where there are no commands, output a single line with the initial floor.

## sample
10
4
call 2
select 5
call 7
select 3
2

5 7 3

</p>