#include<iostream>
#include<string>
#include<set>

struct less{
static bool flag;
bool operator()(const std::string &x, const std::string &y) const{
return flag ? x < y : y < x;
}
};

bool less::flag = false;

int main(int argc, char* argv[]){
less::flag = argc < 2;

std::multiset<std::string, less> dic;

for(std::string str; std::getline(std::cin, str);)
dic.insert(str);

for(std::multiset<std::string, less>::iterator it = dic.begin(); it != dic.end(); ++it)
std::cout << *it << std::endl;
}

std::sort禁止じゃないし
やっぱCなんだろうな