Inception

Dom Cobb and his partner Arthur perform illegal stuffs by entering the subconscious minds of their targets. They use two-level dream within a dream strategy to extract valuable information. Dreamers are awakened either by a sudden shock (a “kick”), or they may die in the dream. Now Dom wants your help. Because he has a complex assignment. He has to go through a lot of people’s dreams. He travels from one person’s dream to another person’s dream. He is too consumed that he can no longer keep track whether he is awake or in someone else’s dream. He will give you n queries to process, each of the queries will be in one of the following forms: ‘Sleep X’ — This means person named X will be sleeping and Dom is going into X’s dream, from the previous person’s dream (if any). ‘Kick’ — This means the current person in whose dream Dom has entered, will be awaken, and Dom will return to the previous person’s dream from where he came to this dream. If Dom is not in anyone’s dream anymore, ignore this query. ‘Test’ — This means Dom wants to know whose dream he is in at the moment. You have to print the person’s name. If Dom is not in anyone’s dream at the moment, you have to print ‘Not in a dream’ (without the quotes). Input First line will contain an integer n (1 ≤ n ≤ 10000), the number of queries. Each of the following n lines will contain one of the three queries mentioned above. For the case of ‘Sleep X’ query, X will be a string composed of only uppercase or lowercase letters and no more than 15 characters long. Output For each of the ‘Test’ queries, print the name of the person whose dream Dom is in right now exactly as it appeared in the input. If Dom is in no one’s dream, output the line ‘Not in a dream’. Check sample input and output for details. Sample Input 20 Sleep Dom Sleep Sakin Test Sleep Asif Sleep Mushfiq Test Kick Test Sleep Shafi Test Kick Test Kick Test

2/2 Kick Test Kick Test Kick Test Sample Output Sakin Mushfiq Asif Shafi Asif Sakin Dom Not in a dream Not in a dream