• + 0 comments
    from collections import defaultdict
    
    # Read the number of strings
    n = int(input())
    
    # Use defaultdict to simplify the counting process
    d = defaultdict(int)
    
    # Read each string and update the count in the dictionary
    for _ in range(n):
        s = input().strip()
        d[s] += 1
    
    # Print the number of unique strings
    print(len(d))
    
    # Print the frequencies of the unique strings
    print(" ".join(map(str, d.values())))