#!/usr/bin/env python
import sys

def bag_of_words(review):
    bag = {}
    for word in review.split(' '):
        if word not in bag:
            bag[word] = 0
        bag[word] += 1
    return bag

def bag_to_string(bag):
    rep = ["%s:%i" % (word, count) for word, count in bag.items()]
    return ' '.join(rep)

if __name__ == "__main__":
    for line in sys.stdin:
        row = line.strip().split(' ', 5)
        if len(row) > 5:
            user_id, item_id, rating, timestamp, word_count, review = row
            print '| %s' % bag_to_string(bag_of_words(review))
