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

int main(void)
{
  int n, m, i, c;
  char buffer[11];

  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    c = 0;
    scanf("%d", &m);
    while (m-- > 0) {
      scanf("%s", buffer);
      if (!strcmp(buffer, "sheep")) {
	c++;
      }
    }
    if (i > 1) {
      printf("\n");
    }
    printf("Case %d: This list contains %d sheep.\n", i, c);
  }

  return 0;
}
