링크 : https://www.acmicpc.net/problem/1181
/*
문제 : 단어 정렬
링크 : https://www.acmicpc.net/problem/6321
*/
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
struct cmp {
bool operator() (const string& a, const string& b) const {
if (a.size() == b.size())
return a < b;
else
return a.size() < b.size();
}
};
int main() {
int n;
cin >> n;
set<string, cmp> v;
for(int i = 0; i < n; i++){
string tmp;
cin >> tmp;
v.insert(tmp);
}
for(auto i : v){
cout << i << '\n';
}
return 0;
}