from itertools import permutations

for names in  permutations(sorted([input() for _ in range(int(input()))])):
    print(", ".join(names))