#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair s_i; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int toint(string in) { if(in == "iti") return 1; if(in == "ni") return 2; if(in == "san") return 3; if(in == "yon") return 4; } string tostr(int in) { if(in == 1) return "iti"; if(in == 2) return "ni"; if(in == 3) return "san"; if(in == 4) return "yon"; } int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector v(N); for(int i = 0; i < N; i++) { cin >> v[i].first; string id; cin >> id; v[i].second = toint(id); } sort(v.begin(), v.end()); for(int i = 0; i < N; i++) { cout << v[i].first << " " << tostr(v[i].second) << endl; } return 0; }