is working very hard for his senpai, . goes home, in his brand new car, named Rimuru. Everyone on DMOJ parks in this driveway, and with car names respective to the names of their username in DMOJ.
cars from the front of the driveway to leave, so if X
is going out and X
is the front car and , X
is allowed to leave. This means that each time someone leaves from the front of the driveway, gets subtracted by .
Each day, there will be one action, either a car coming in or out. days.
now wants to know the cars that are still in the strip of land afterInput Specification
Two integers, and .
Next lines: 2 space separated Strings and . The name of the person's car that's being parked and whether they are leaving the driveway or not.
will always be either in
or out
, and will always consist of lowercase, uppercase English letters and numbers.
Output Specification
Output the car's names in order starting from the most inner car that is still in the driveway after days, each on a separate line.
Sample Input
8 2
Xyene in
quantum in
magicalsoup in
bruce in
magicalsoup out
Xyene out
quantum out
quantum in
Sample Output
magicalsoup
bruce
quantum
Sample Explanation
The names are the cars in the driveway, as they come in from the right.
Day | Cars in Driveway |
---|---|
Xyene | |
Xyene, quantum | |
Xyene, quantum, magicalsoup | |
Xyene, quantum, magicalsoup, bruce | |
Xyene, quantum, magicalsoup, bruce | |
quantum, magicalsoup, bruce | |
magicalsoup, bruce | |
magicalsoup, bruce, quantum |
Comments