Flip Horizontally – Matrix Sum: The program must accept two integer matrices M1 and M2 of size RxC as the input. The program must flip the matrix M2 horizontally (i.e., reversing each row of the matrix). Then the program must print the sum of integers in two matrices M1 and M2 at the same positions.
Boundary Condition(s):
2 <= R, C <= 50
1 <= Matrix element value <= 1000
Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C integers representing the matrix M1.
The next R lines from the (R+2)th line, each contains C integers representing the matrix M2.
Output Format:
The first R lines, each contains C integers separated by a space.
Example Input/Output 1:
Input:
3 3
10 20 30
40 50 60
70 80 90
100 200 300
400 500 600
700 800 900
Output:
310 220 130
640 550 460
970 880 790
Explanation:
After flipping the matrix M2 horizontally, the matrix becomes
300 200 100
600 500 400
900 800 700
The sum of integers in two matrices M1 and M2 at the same positions is given below.
310 220 130
640 550 460
970 880 790
Example Input/Output 2:
Input:
3 5
51 60 63 45 64
70 71 27 44 51
16 67 49 51 70
30 17 79 80 48
79 29 59 21 51
84 76 62 48 28
Output:
99 140 142 62 94
121 92 86 73 130
44 115 111 127 154
m,n = map(int,input().split())
a = []
b = []
for i in range(m):
x = list(map(int,input().split()))
a.append(x)
for j in range(m):
y = list(map(int,input().split()))
b.append(y[::-1])
for i in range(m):
for j in range(n):
s = a[i][j]+b[i][j]
print(s,end=" ")
print()