#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

string itoa(int n)
{
    stringstream ss;
	ss <<n;
	return ss.str();
}

string gen_hash(string s)
{
	int count[26];
	string hash="";
	fill_n(count,26,0);
	for (int i = 0; i < s.size(); ++i)
	{
		++count[s[i]-'a'];
	}
	for (int i = 0; i < 26; ++i)
	{
		if(count[i]!=0)
		{
			hash+=('a'+i);
			hash+=itoa(count[i]);
		}
	}
	return hash;
}

int main()
{
	int N;
	string S;
	map<string,set<string> > anagram_group;
	set<set<string> > sorted;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> S;
		anagram_group[gen_hash(S)].insert(S);
	}
	for (map<string,set<string> >::iterator i = anagram_group.begin(); i != anagram_group.end(); ++i)
	{
		sorted.insert(i->second);
	}
	for (set<set<string> >::iterator i = sorted.begin(); i != sorted.end(); ++i)
	{
		for (set<string>::iterator j = i->begin(); j!= i->end() ; ++j)
		{
			cout<<*j<<" ";
		}
		cout<<"\n";
	}
	return 0;
}