#include <stdio.h>

#define maxn 1000
#define mlen 200

char *f[] = {"Slytherin", "Hufflepuff", "Gryffindor", "Ravenclaw"};
char name[maxn][mlen + 1];
char s[mlen + 1];
int an[4], a[4][maxn];

int main()
{
  int n, i, k;

  scanf("%d ", &n);
  for (i = 0; i < n; i++)
  {
    gets(name[i]);
    gets(s);
    for (k = 0; s[0] != f[k][0]; k++)
      ;
    a[k][an[k]++] = i;
  }
  for (k = 0; k < 4; k++)
  {
    if (k)
      puts("");
    printf("%s:\n", f[k]);
    for (i = 0; i < an[k]; i++)
      printf("%s\n", name[a[k][i]]);
  }
  return 0;
}