class Solution:def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:l = len(colsum)if upper + lower != sum(colsum):return []num_two = colsum.count(2)if num_two > lower or num_two > upper:return []matrix = [[-1] * l , [-1] * l]to_resolve = []for i, col in enumerate(colsum):if col == 0:matrix[0][i] = 0matrix[1][i] = 0if col == 2:matrix[0][i] = 1matrix[1][i] = 1if col == 1:to_resolve.append(i)diffs = lower - upperfor r in to_resolve:if diffs > 0:matrix[0][r] = 0matrix[1][r] = 1diffs -= 1else:matrix[0][r] = 1matrix[1][r] = 0diffs += 1return matrix