#include using namespace std; #define rep(i,n) for(int i = 0; i < int(n); i++) using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; vector> vp; rep(i,n){ string s,t; cin >> s >> t; int num; if(t == "iti") num = 1; else if(t == "ni") num = 2; else if(t == "san") num = 3; else if(t == "yon") num = 4; vp.push_back({s,num}); } sort(vp.begin(),vp.end()); for(auto v : vp){ cout << v.first << " "; if(v.second == 1) cout << "iti" << endl; else if(v.second == 2) cout << "ni" << endl; else if(v.second == 3) cout << "san" << endl; else if(v.second == 4) cout << "yon" << endl; } return 0; }