def soma_matrizes(m1, m2):
import numpy as np
m1 = np.array(m1)
m2 = np.array(m2)
if m1.shape != m2.shape:
return False
else:
return (m1 + m2).tolist()
m1 = [[1, 2, 3],[4, 5, 6]]
m2 = [[2, 3, 4],[5, 6, 7]]
print(soma_matrizes(m1, m2))
m1 = [[1], [2], [3]]
m2 = [[2, 3, 4],[5, 6, 7]]
print(soma_matrizes(m1, m2))
ZGVmIHNvbWFfbWF0cml6ZXMobTEsIG0yKToKCWltcG9ydCBudW1weSBhcyBucAoJbTEgPSBucC5hcnJheShtMSkKCW0yID0gbnAuYXJyYXkobTIpCglpZiBtMS5zaGFwZSAhPSBtMi5zaGFwZToKCQlyZXR1cm4gRmFsc2UKCWVsc2U6CgkJcmV0dXJuIChtMSArIG0yKS50b2xpc3QoKQoKbTEgPSBbWzEsIDIsIDNdLFs0LCA1LCA2XV0KbTIgPSBbWzIsIDMsIDRdLFs1LCA2LCA3XV0JCnByaW50KHNvbWFfbWF0cml6ZXMobTEsIG0yKSkKCm0xID0gW1sxXSwgWzJdLCBbM11dCm0yID0gW1syLCAzLCA0XSxbNSwgNiwgN11dCQpwcmludChzb21hX21hdHJpemVzKG0xLCBtMikp