#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
int a[x][y],b[x][y],c[x][y];
for(int i=0;i<x;i++){
for(int j=0;j<x;j++){
cin>>a[i][j];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<x;j++){
cin>>b[i][j];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<x;j++){
c[i][j]=a[i][j]+b[i][j];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<x;j++){
cout<<c[i][j]<<" ";
}
cout<<endl;
}
return 0;
}