i=input n=int(i()) m=int(i()) A=[list(map(int, i().split())) for _ in '1'*m] B=[0]*m for _ in range(n-1): new_B = [0]*m for j in range(m): new_B[j] = max([B[k]+A[k][j] for k in range(m)]) B = new_B print(max(new_B))