• + 0 comments

    from collections import Counter

    n = int(input().strip()) words = [input().strip() for _ in range(n)]

    words_count = Counter(words)

    distinct = [] for w in words: if w not in distinct: distinct.append(w)

    print(len(distinct))

    for d in distinct: print(words_count[d], end=" ") print()