def solve(self, cipher):
        """
        f[i][j] represents the number of combinations for size i*j wall, not necessarily solid
        f[i][j] = f[1][j]**i

        s[i][j] represents the number of combinations for size i*j wall, solid

        s[h][w]  = f(h,w) - sum(f[h][w-i]*s[h][i] for i)

        To solve TLE:
        1. s[h][w] not rely on previous h, simplify to s[w]
        2. power takes time, take memory to save time for f[1][j]**i

        :param cipher:
        :return:
        """
        N, M = cipher
        f = [0 for _ in xrange(M + 1)]
        s = [0 for _ in xrange(M + 1)]

        f[0] = 1
        for j in xrange(1, M + 1):
            for l in self.lens:
                if j - l >= 0:
                    f[j] += f[j - l]
                f[j] %= MOD

        f_N = map(lambda x: pow(x, N, MOD), f)

        for j in xrange(1, M + 1):
            s[j] = f_N[j]
            if s[j] <= 0: break
            for k in xrange(1, j):  # sum
                s[j] -= f_N[k - j] * s[k]
                s[j] %= MOD
        return s[M]
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/Lego Blocks.py/Solution.solve/swapped operands of `-`