class Solution(object):

def matrixReshape(self, nums, r, c):

"""

:type nums: List[List[int]]

:type r: int

:type c: int

:rtype: List[List[int]]

"""

mid = []

for x in nums:

mid.extend(x)

return [mid[i*c:i*c+c] for i in range(r)] if len(mid) == r*c else nums