import copy


def Compu_B_Backw(MBackw, n):
    """Compute possible positions to shift monomials
    Parameters
    ----------
    MBackw : list
        monomials to be shifted, for example, [[1], [2], [1]]
    n : int
        size of the NLFSR
    Return
    ----------
    BBackw : list
        positions to shift monomials, for example, [1, 1, 3]
    """

    BBackw = []
    for i in range(len(MBackw)):
        m = copy.deepcopy(MBackw[i])
        b = n - 1 - max(m) - 1
        BBackw.append(b)
    return BBackw