/* Aufgabe A, Ulm Local Contest 2000 by Peter Schaeffer */

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

char w[100000][40], sw[100000][40];
int mw, i, j, pos;
int s[100000], bf[6], bs[6];

int sortf(const int *a, const int *b)
{
  int merk;
  merk = strcmp(sw[*a], sw[*b]);
  if (merk) return merk;
  return strcmp(w[*a], w[*b]);
}

int sortw(const char *a, const char *b)
{
  if (*a<*b) return -1;
  if (*a>*b) return 1;
  return 0;
}

int main()
{
  FILE *input = stdin;
  mw = 0;
  while(fscanf(input, " %s ", w[mw++])>0);
  for(i=0; i<5; i++) bf[i] = -1;
  for(i=0; i<mw; i++)
    {
      s[i] = i;
      for(j=0; j<40; j++)
	{
	  sw[i][j] = w[i][j];
	  if (w[i][j] == 0) break;
	}
      qsort(sw[i], j, 1, (int (*)(const void*, const void*))sortw);
    }
  qsort(s, mw, 4, (int (*)(const void*, const void*))sortf);
  pos = 0;
  while(pos<mw)
    {
      int x = pos;
      while(x<mw)
	{
	  if (strcmp(sw[s[pos]], sw[s[x]])) break;
	  x++;
	}
      for(i=4; i>= 0; i--)
	{
	  if (x-pos < bs[i] ||
              x-pos == bs[i] && strcmp(w[s[pos]], w[s[bf[i]]]) > 0) break;
	  bf[i+1] = bf[i];
	  bs[i+1] = bs[i];
	}
      bf[i+1] = pos;
      bs[i+1] = x-pos;
      pos = x;
    }
  for(i=0; i<5; i++)
    {
      if (bf[i] <=0) break;
      printf("Group of size %d: ", bs[i]);
      for(j=bf[i]; j<bf[i]+bs[i]; j++)
        if (j==bf[i] || strcmp(w[s[j]], w[s[j-1]])) printf("%s ",w[s[j]]);
      printf(".\n");
    }
  fclose(input);
  return 0;
}
