// https://szkopul.edu.pl/problemset/problem/Aq-3LEQBYOdbiqQXvn3TJ0Id/site/?key=statement
#include <bits/stdc++.h>
// using namespace std;
// #define GARY_DBG
#define GARY_LIB
#define int long long
constexpr int sizik = 1000 * 1001;
#define ar std::array
#define pr std::pair
#define vec std::vector
typedef vec<vec<int>> _kra;
void solve() {
std::map<std::string, std::set<std::string>> e;
int n;
std::cin >> n;
for (int i = 0; i < n; i++) {
std::string s;
std::cin >> s;
std::string s1 = s;
std::sort(s1.begin(), s1.end());
e[s1].insert(s);
}
std::vector<std::string> rep;
for (const auto& [a, b] : e) {
rep.push_back(*b.begin());
}
std::sort(rep.begin(), rep.end());
for (const auto& a : rep) {
std::string s1 = a;
std::sort(s1.begin(), s1.end());
for (const auto& b : e[s1]) {
std::cout << b << " ";
}
std::cout << '\n';
}
}
int32_t main() {
#ifndef GARY_DBG
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
#endif
int t = 1;
// std::cin >> t;
for (; t > 0; t--) {
solve();
}
return 0;
}