database = {}

def learn(sentence):
    # Tip: 'hello world'.split()
    # returns ['hello', 'world']

    # Insert some code here...

    # ... then for each word:
    # we get the set of the successors
    # of words[i] (or an empty set)
    next_words = database.get(words[i], set())

    # we append to it one new successor
    next_words.add(words[i + 1])

    # and we put the set of successors
    # in the database
    database[words[i]] = next_words

learn(raw_input())