#include using namespace std; int strToi(string &s){ if(s == "iti") return 1; else if(s == "ni") return 2; else if(s == "san") return 3; else if(s == "yon") return 4; return 0; } int main() { int n; cin >> n; vector> sId(n); string tmp; for(int i = 0; i < n; i++){ cin >> sId[i].first; cin >> tmp; sId[i].second = strToi(tmp); } sort(sId.begin(), sId.end()); for(const auto& str: sId){ cout << str.first << " " << str.second << endl; } }