Implement a function to perform matrix multiplication from scratch. Use the signature matrix_multiply(A, B), where A and B are non-empty rectangular lists of numbers, and return a new matrix containing their product without modifying either input. If A has shape m x n, B must have shape n x p, and the result has shape m x p; for example, [[1, 2]] multiplied by [[3], [4]] returns [[11]].
def matrix_multiply(A, B):