#include #define rep(i,n)for(long long i=0;i<(long long)(n);++i) #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD=1000000007; const ll INF=1e18; const int MAX=510000; const double pi=acos(-1); int dx[8] = {1,0,-1,0,1,1,-1,-1}; int dy[8] = {0,1,0,-1,-1,1,1,-1}; int main(){ cin.tie(0); ios::sync_with_stdio(false); vector>ans; int n; cin >> n; rep(i,n){ string s,t; cin >> s >> t; if(t=="iti")ans.emplace_back(s,1); if(t=="ni")ans.emplace_back(s,2); if(t=="san")ans.emplace_back(s,3); if(t=="yon")ans.emplace_back(s,4); } sort(ans.begin(),ans.end()); rep(i,n){ cout << ans[i].first << " "; if(ans[i].second==1)cout << "iti"; if(ans[i].second==2)cout << "ni"; if(ans[i].second==3)cout << "san"; if(ans[i].second==4)cout << "yon"; cout << endl; } return 0; }