#include <iostream>
using namespace std;
int main() {
int n,m;
cin>>n>>m;
int a[n+1][m+1];
long long pr[n+2][m+2]={};
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
cin>>a[i][j];
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
pr[i][j]=pr[i-1][j]+pr[i][j-1]-pr[i-1][j-1]+a[i][j];
for(int i=0; i<=n; i++){
for(int j=0; j<=m; j++)
cout<<pr[i][j]<<" ";
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbixtOwoJY2luPj5uPj5tOwoJaW50IGFbbisxXVttKzFdOwoJbG9uZyBsb25nIHByW24rMl1bbSsyXT17fTsKCWZvcihpbnQgaT0xOyBpPD1uOyBpKyspCgkJZm9yKGludCBqPTE7IGo8PW07IGorKykKCQkJY2luPj5hW2ldW2pdOwoJZm9yKGludCBpPTE7IGk8PW47IGkrKykKCQlmb3IoaW50IGo9MTsgajw9bTsgaisrKQoJCXByW2ldW2pdPXByW2ktMV1bal0rcHJbaV1bai0xXS1wcltpLTFdW2otMV0rYVtpXVtqXTsKCWZvcihpbnQgaT0wOyBpPD1uOyBpKyspewoJCWZvcihpbnQgaj0wOyBqPD1tOyBqKyspCgkJY291dDw8cHJbaV1bal08PCIgIjsKCWNvdXQ8PGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==