def dfs(i, j): if i == n and j == m: temp.append(1) return for k in range(2): ...