#include using namespace std; struct FastCin{static constexpr int S=1<<25;char b[S+32],*p=b;FastCin(){size_t n=fread(b,1,S,stdin);memset(b+n,0,32);}inline FastCin&operator>>(int&x){while(*p<'0'||*p>'9')++p;x=0;do{x=x*10+*p++-'0';}while(*p>='0'&&*p<='9');return *this;}}; struct FastCout{static constexpr unsigned int S=1<<24;char b[S],*p=b;~FastCout(){fwrite(b,1,p-b,stdout);}inline FastCout&operator<<(char c){*p++=c;return *this;}inline FastCout&operator<<(unsigned int x){char*q=p;if(!x){*p++='0';return*this;}unsigned int n=0,y=x;while(y)y/=10,++n;p+=n;for(char*r=p;r!=q;)*--r='0'+x%10,x/=10;return*this;}}; FastCin Cin; FastCout Cout; int main(){ int H, W; Cin >> H >> W; int A[H][W]; for (int i = 0; i < H; i++){ for (int j = 0; j < W; j++){ Cin >> A[i][j]; } } unsigned int S[H]; for (int i = 0; i < H; i++){ S[i] = 0; for (int j = 0; j < W; j++){ S[i] += A[i][j]; } } unsigned int T = 0; for (int i = 0; i < H; i++){ T += S[i]; } for (int i = 0; i < H; i++){ Cout << (S[i] + T) << '\n'; } }