def prettyPrint(perms, path, om):
    """
    Generates a sequence of numbers that includes all permutations and
    is the shortest one. Basically, forms a solution from list of indexes.
    :param perms: list of all permutations
    :param path: list of indices that tells the sequence of perms
    :param om: overlap matrix, used to efficiently concat perms
    """

    string = "".join(str(x+1) for x in perms[path[0]])  # natural numbers instead of 0+
    for i in range(1, len(path)):
        startString = om[path[i-1]][path[i]]
        string += "".join(str(x+1) for x in perms[path[i]][startString:])

    return string, len(string)