#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(const string& a, const string& b) {
int len = max(a.size(), b.size());
for(int i = 0; i < len; i++) {
char ac = i < a.size() ? a[i] : a[0];
char bc = i < b.size() ? b[i] : b[0];
if(ac > bc) return true;
else if(ac < bc) return false;
}
return false;
}
int main() {
string number;
vector<string> numbers;
while(cin >> number) {
numbers.push_back(number);
}
sort(numbers.begin(), numbers.end(), cmp);
for(int i = 0; i < numbers.size(); i++) {
cout << numbers[i] << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYm9vbCBjbXAoY29uc3Qgc3RyaW5nJiBhLCBjb25zdCBzdHJpbmcmIGIpIHsKCWludCBsZW4gPSBtYXgoYS5zaXplKCksIGIuc2l6ZSgpKTsKCWZvcihpbnQgaSA9IDA7IGkgPCBsZW47IGkrKykgewoJCWNoYXIgYWMgPSBpIDwgYS5zaXplKCkgPyBhW2ldIDogYVswXTsKCQljaGFyIGJjID0gaSA8IGIuc2l6ZSgpID8gYltpXSA6IGJbMF07CgkJaWYoYWMgPiBiYykgcmV0dXJuIHRydWU7CgkJZWxzZSBpZihhYyA8IGJjKSByZXR1cm4gZmFsc2U7Cgl9CglyZXR1cm4gZmFsc2U7Cn0KCmludCBtYWluKCkgewoJc3RyaW5nIG51bWJlcjsKCXZlY3RvcjxzdHJpbmc+IG51bWJlcnM7Cgl3aGlsZShjaW4gPj4gbnVtYmVyKSB7CgkJbnVtYmVycy5wdXNoX2JhY2sobnVtYmVyKTsKCX0KCXNvcnQobnVtYmVycy5iZWdpbigpLCBudW1iZXJzLmVuZCgpLCBjbXApOwoJZm9yKGludCBpID0gMDsgaSA8IG51bWJlcnMuc2l6ZSgpOyBpKyspIHsKCQljb3V0IDw8IG51bWJlcnNbaV0gPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9