Inception (UVA 13055) by ynu_a
Contest: 3738    RunID: 20173722    Status: Accepted    Date: Sat Oct 14 14:16:33 JST 2017


#include<bits/stdc++.h>
using namespace std;

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

typedef long long ll;
typedef pair<int, int> ii;

int main(){

  int n;
  cin >> n;
  stack<string> st;
  while(n--){
    string s;
    cin >> s;
    if(s == "Sleep"){
      cin >> s;
      st.push(s);
    }
    else if(s == "Kick"){
      if(!st.empty()) st.pop();
    }
    else{
      if(st.empty()) cout << "Not in a dream" << endl;
      else cout << st.top() << endl;
    }
  }

  return 0;
}