#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss stable_sort
#define ll long long
struct cmp {
bool operator()(const string& a, const string& b) const {
return a > b;
}
};
int main() {
cin.tie(0)->sync_with_stdio(0);
// for(int i=0; i< n;i++)
int n;
cin >> n;
vector<string> v;
set<string> se;
while (n--) {
string s, s2;
cin >> s >> s2;
if (s2 == "enter") {
se.emplace(s);
}
else {
se.erase(s);
}
}
/*for (auto i : se) {
cout << i << "\n";
}*/
for (auto it = se.rbegin(); it != se.rend(); it++) {
cout << *it<<"\n";
}
return 0;
}