def similarity_to_pattern(similarity: int) -> str:
    """
    Inverse of pattern_to_similarity for 5 digit in base 3.
    :param similarity: str
    :return: pattern
    """
    pattern = ''
    for i in range(5):
        pattern += str(similarity % (3 ** (i + 1)) // 3 ** i)
    return pattern