def __update_count(count, max_count):
    """
    Updating count for next permutation. If all permutations are 
    done, return -1 as stoping criteria.

    :param max_count: list
    :param count: list
    :return: list
    """
    n = len(count)
    for i in range(n):
        if (count[n-i-1]) < max_count[n-i-1]:
            count[n-i-1] += 1
            break
        elif count == max_count:
            count = -1
            break
        else:
            count[n-i-1] = 0
    return count