def matrix_union(A, B):
for a, b in zip(A, B):
yield [*a, *b]
A = [
[0, 0, 1],
[0, 1, 0],
[1, 0, 1]
]
B = [
[2, 2, 3],
[3, 2, 2],
[3, 3, 3]
]
print(list(matrix_union(A, B)))
ZGVmIG1hdHJpeF91bmlvbihBLCBCKToKICAgIGZvciBhLCBiIGluIHppcChBLCBCKToKICAgICAgICB5aWVsZCBbKmEsICpiXQoKQSA9IFsKICAgIFswLCAwLCAxXSwKICAgIFswLCAxLCAwXSwKICAgIFsxLCAwLCAxXQpdCgpCID0gWwogICAgWzIsIDIsIDNdLAogICAgWzMsIDIsIDJdLAogICAgWzMsIDMsIDNdCl0KCnByaW50KGxpc3QobWF0cml4X3VuaW9uKEEsIEIpKSk=
[[0, 0, 1, 2, 2, 3], [0, 1, 0, 3, 2, 2], [1, 0, 1, 3, 3, 3]]