try:
while True:
row,col=map(int,input().split())
n=[[0 for j in range(row)] for i in range(col)]
A=[]
for i in range(row):
num=input().split()
A.append(num)
for ii in range(row):
for jj in range(col):
n[jj][ii]+=int(A[ii][jj])
for iii in n:
jjj=[str(v) for v in iii]
print(' '.join(jjj))
except EOFError:
pass