d6e7ad35e8e92e77fd59829c72f6c66deb700533ae575b8a5e57d48393199ab2
// https://szkopul.edu.pl/problemset/problem/ERz8Uez5UFnNbPH2Jn965eZ3/site/?key=statement
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
std::cin >> n;
std::vector<std::string> v(n);
for (int i = 0; i < n; i++) {
std::cin >> v[i];
}
std::sort(v.begin(), v.end(), [](std::string& a, std::string& b) {
if (a.size() < b.size()) {
return true;
} else if (a.size() == b.size()) {
return a < b;
} else {
return false;
}
});
for (const auto& s : v) {
std::cout << s << '\n';
}
return 0;
}