﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem_01_Wardrobe
{
    class Program_01_Wardrobe
    {
        static void Main()
        {
            Dictionary<string, Dictionary<string, int>> wardrobe = new Dictionary<string, Dictionary<string, int>>();
            LoadWardrobe(wardrobe);
            PrintWardrobe(wardrobe);
        }

        private static void PrintWardrobe(Dictionary<string, Dictionary<string, int>> wardrobe)
        {
            string[] seekLine = Console.ReadLine().Split(' ');
            string seekColor = seekLine[0];
            string seekItem = seekLine[1];
            foreach (var colorItem in wardrobe)
            {
                Console.WriteLine($"{colorItem.Key} clothes:");
                foreach (var item in colorItem.Value)
                {
                    string isFound = ((colorItem.Key == seekColor) && (item.Key == seekItem)) ? " (found!)" : string.Empty;
                    Console.WriteLine($"* {item.Key} - {item.Value}{isFound}");
                }
            }
        }

        private static void LoadWardrobe(Dictionary<string, Dictionary<string, int>> wardrobe)
        {
            int inputLinesCount = int.Parse(Console.ReadLine());
            for (int i = 0; i < inputLinesCount; i++)
            {
                string[] splitedLine = Console.ReadLine()
                    .Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
                string color = splitedLine[0];
                splitedLine = splitedLine[1].Split(',');
                foreach (var item in splitedLine)
                {
                    if (!wardrobe.ContainsKey(color))
                    {
                        wardrobe.Add(color, new Dictionary<string, int>());
                    }

                    if (!wardrobe[color].ContainsKey(item))
                    {
                        wardrobe[color].Add(item, 0);
                    }

                    wardrobe[color][item]++;
                }
            }
        }
    }
}