//* Problem  : 1340 - Anagram Groups
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.08.11
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define swap(xxx, yyy) (xxx) ^= (yyy) ^= (xxx) ^= (yyy)

struct an{
	int map[26];
	char word[100];
	int len;
	int count;
	int start;
} a[100000], b[100000];

int n, m;
char s[100];

void map(int k)
{
	int i;
	a[k].len = strlen(s); strcpy(a[k].word, s);
	memset(a[k].map, 0, sizeof(a[0].map));
	for (i = 0; s[i]; i++)
		a[k].map[s[i]-'a']++;
}

int cmp_map(const void * a, const void *b)
{
	int i;
	an * aa = (an*)a, * bb = (an*)b;
	for (i = 0; i < 26; i++)
		if (aa->map[i] != bb->map[i]) return (aa->map[i] - bb->map[i]);
	for (i = 0; aa->word[i] && bb->word[i]; i++)
		if (aa->word[i] != bb->word[i]) return (aa->word[i] - bb->word[i]);
	return 0;
}

int cmp_count(const void * a, const void *b)
{
	an * aa = (an*)a, * bb = (an*)b;
	if (aa->count != bb->count) return - (aa->count - bb->count);
	return (strcmp(aa->word, bb->word));
}

int cmp(int k1, int k2)
{
	for (int i = 0; i < 26; i++)
		if (a[k1].map[i] != a[k2].map[i]) return (a[k1].map[i] != a[k2].map[i]);
	return 0;
}

int main()
{
	n = 0;
	while (scanf("%s", s) == 1)
	{
		map(n++);
	}
	int i, st, j, k;
	qsort(a, n, sizeof(a[0]), cmp_map);
/*
						for (i = 0; i < n; i++)
						{
							printf("%s ", a[i].word);
							for (j = 0; j < 26; j++) printf("%d ", a[i].map[j]);
							printf("\n");
						}
*/
	m = 0; i = 0;
	while (i < n)
	{
		st = i;
		while (!cmp(i, st)) i++;
		b[m] = a[st];
		b[m].start = st;
		b[m++].count = i - st;
	}
	qsort(b, m, sizeof(b[0]), cmp_count);
/*
				printf("\n\n");
				for (i = 0; i < m; i++)
					printf("%d %s\n", b[i].count, b[i].word);
*/
	for (i = 0; i < 5 && i < m; i++)
	{
		k = b[i].count;
		printf("Group of size %d: ", k);
		j = b[i].start;
		while (k--) if (strcmp(a[j].word, a[j-1].word))printf("%s ", a[j++].word); else j++;
		printf(".\n");
	}

}