#include #include using namespace std; using namespace atcoder; using ll=long long; using ull=unsigned long long; using ld=long double; using i128=__int128; using P=pair; template using vc=vector; template using vv=vc>; using vl=vc; using vvl=vc>; using vul=vc; using vs=vc; using vb=vc; #define rep(i,s,n) for(ll i=s;i<(n);i++) #define Rep(i,s,n) for(ll i=n;i>=s;i--) #define nall(x) x.begin(),x.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back #define pob pop_back #define nexp(v) next_permutation(v) #define prep(v) prev_permutation(v) #define YES cout<<"Yes"<b)a=b;} void chmax(ll &a,ll b){if(a inline T read(){ if(!initialized)init(); while(1){ while(*p<'0' || '9'<*p){ if(*p==0){ if(!refill())return T(0); }else{ ++p; } } T x=0; while(1){ while('0'<=*p && *p<='9'){ x=x*10+(*p-'0'); ++p; } if(*p!=0)return x; if(!refill())return x; if(*p<'0' || '9'<*p)return x; } } } inline void write_u32(uint32_t x,char *&q){ auto [n,ec]=to_chars(q,q+10,x); q=n; } } using namespace fastio; int main(){ init(); int h=read(),w=read(); vc s(h); uint32_t t=0; rep(i,0,h){ uint32_t sum=0; rep(j,0,w){ uint32_t a=read(); sum+=a; t+=a; } s[i]=sum; } char *b=buf; rep(i,0,h){ write_u32(s[i]+t,b); *b++=endl; } ::write(1,buf,b-buf); }