def find_prefix_entry(message, dictionary):
    """
    Find the longest entry in dictionary which is a prefix of the given message
    """
    for entry in dictionary[::-1]:
        if message.startswith(entry[0]):
            return dictionary.index(entry)
    return -1