Scores of Final Examination

I am a junior high school teacher. The final examination has just finished, and I have all the students' scores of all the subjects. I want to know the highest total score among the students, but it is not an easy task as the student scores are listed separately for each subject. I would like to ask you, an excellent programmer, to help me by writing a program that finds the total score of a student with the highest total score.

Input

The input consists of multiple datasets, each in the following format.

> n m
>  p1,1 p1,2 … p1,n
>  p2,1 p2,2 … p2,n
>  …
>  pm,1 pm,2 … pm,n
>

The first line of a dataset has two integers n and m. n is the number of students (1 ≤ n ≤ 1000). m is the number of subjects (1 ≤ m ≤ 50). Each of the following m lines gives n students' scores of a subject. pj,k is an integer representing the k-th student's score of the subject j (1 ≤ j ≤ m and 1 ≤ k ≤ n). It satisfies 0 ≤ pj,k ≤ 1000.

The end of the input is indicated by a line containing two zeros. The number of datasets does not exceed 100.

Output

For each dataset, output the total score of a student with the highest total score. The total score sk of the student k is defined by sk = p1,k + … + pm,k.

Sample Input


5 2
10 20 30 40 50
15 25 35 45 55
6 3
10 20 30 15 25 35
21 34 11 52 20 18
31 15 42 10 21 19
4 2
0 0 0 0
0 0 0 0
0 0


Output for the Sample Input


105
83
0






Example

Input

5 2
10 20 30 40 50
15 25 35 45 55
6 3
10 20 30 15 25 35
21 34 11 52 20 18
31 15 42 10 21 19
4 2
0 0 0 0
0 0 0 0
0 0


Output

105
83
0

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
while True:
	(n, m) = map(int, input().split())
	if n == 0 and m == 0:
		break
	p = [list(map(int, input().split())) for i in range(m)]
	for i in range(1, m):
		for j in range(n):
			p[i][j] += p[i - 1][j]
	print(max(p[m - 1]))


while True:
	(n, m) = map(int, input().split())
	if n + m == 0:
		break
	a = [list(map(int, input().split())) for i in range(m)]
	for i in range(1, m):
		for j in range(n):
			a[i][j] += a[i - 1][j]
	print(max(a[m - 1]))


while True:
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		break
	kei = [0 for _ in range(a)]
	for i in range(b):
		line = list(map(int, input().split()))
		for j in range(0, a):
			kei[j] += line[j]
	print(max(kei))


for i in range(110):
	(x, y) = map(int, input().split())
	if x == y == 0:
		break
	else:
		a = [0] * x
		for j in range(y):
			ls = list(map(int, input().split()))
			for _ in range(x):
				a[_] += ls[_]
		print(max(a))


while True:
	(a, b) = list(map(int, input().split(' ')))
	if a == 0 and b == 0:
		break
	score = [[0] for i in range(b)]
	for i in range(b):
		score[i] = list(map(int, input().split()))
	sum = 0
	maxSum = 0
	for i in range(a):
		sum = 0
		for j in range(b):
			sum += score[j][i]
			if sum > maxSum:
				maxSum = sum
	print(maxSum)


import os, re, sys, operator
from collections import Counter, deque
from operator import itemgetter
from itertools import accumulate, combinations, groupby
from sys import stdin, setrecursionlimit
from copy import deepcopy
import heapq
setrecursionlimit(10 ** 6)
while 1:
	(n, m) = map(int, stdin.readline().rstrip().split())
	if (n, m) == (0, 0):
		break
	a = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)]
	print(max((sum(i) for i in zip(*a))))


while 1:
	(n, m) = map(int, input().split())
	if n == 0:
		break
	a = []
	for _ in range(m):
		a.append(list(map(int, input().split())))
	b = []
	for i in range(n):
		s = 0
		for j in range(m):
			s += a[j][i]
		b.append(s)
	print(max(b))


scores = [[0] * 51 for i in range(1001)]
while 1:
	try:
		(n, m) = (int(x) for x in input().split())
		if n == 0:
			break
		for i in range(0, m):
			scores[i] = list((int(x) for x in input().split()))
		maxSum = 0
		for i in range(0, n):
			sum = 0
			for j in range(0, m):
				sum += scores[j][i]
			maxSum = max(maxSum, sum)
		print(maxSum)
	except:
		break


while True:
	(n, m) = map(int, input().split())
	if n == m == 0:
		break
	else:
		score = [0] * n
		for i in range(m):
			p = list(map(int, input().split()))
			for j in range(n):
				score[j] += p[j]
		print(max(score))


while 1:
	(N, M) = map(int, input().split())
	if N == 0:
		break
	S = [list(map(int, input().split())) for i in range(M)]
	ans = 0
	for i in range(N):
		ans = max(ans, sum((S[j][i] for j in range(M))))
	print(ans)


while True:
	(n, m) = map(int, input().split())
	if n == m == 0:
		break
	students = [0 for _ in range(n)]
	for _ in range(m):
		scores = list(map(int, input().split()))
		for i in range(n):
			students[i] += scores[i]
	print(max(students))


while True:
	(n, m) = map(int, input().split())
	if n == m == 0:
		break
	score = [0 for i in range(n)]
	for i in range(m):
		hokan = list(map(int, input().split()))
		for j in range(n):
			score[j] += hokan[j]
	score.sort(reverse=True)
	print(score[0])


def main():
	(n, k) = map(int, input().split())
	if n * k == 0:
		return False
	ans = [0 for _ in range(n)]
	for _ in range(k):
		a = list(map(int, input().split()))
		for i in range(n):
			ans[i] += a[i]
	print(max(ans))
	return True
while main():
	pass


while True:
	(n, m) = map(int, input().split())
	if n + m == 0:
		break
	li = list()
	for i in range(m):
		line = [num for num in map(int, input().split())]
		li.append(line)
	ans = [0 for i in range(n)]
	for i in range(m):
		for j in range(n):
			ans[j] += li[i][j]
	print(max(ans))


while True:
	n = [int(e) for e in input().split()]
	if n[0] == 0 and n[1] == 0:
		break
	m = [[0 for i in range(n[0])] for j in range(n[1] + 1)]
	for j in range(n[1]):
		m[j] = [int(e) for e in input().split()]
	for k in range(n[0]):
		score = 0
		for j in range(n[1]):
			score = m[j][k] + score
		m[n[1]][k] = score
	max_ = m[n[1]][0]
	for k in range(n[0]):
		if max_ < m[n[1]][k]:
			max_ = m[n[1]][k]
	print(max_)


import sys

def solve(n, m):
	scores = [[int(x) for x in input().split()] for _ in range(m)]
	return max([sum(z) for z in zip(*scores)])

def main(args):
	while True:
		(n, m) = map(int, input().split())
		if n == 0 and m == 0:
			break
		ans = solve(n, m)
		print(ans)
main(sys.argv[1:])


import sys
import math

class mymath:
	pi = 3.141592653589793

	def pnum_eratosthenes(self, n):
		ptable = [0 for i in range(n + 1)]
		plist = []
		for i in range(2, n + 1):
			if ptable[i] == 0:
				plist.append(i)
				for j in range(i + i, n + 1, i):
					ptable[j] = 1
		return plist

	def pnum_check(self, n):
		if n == 1:
			return False
		elif n == 2:
			return True
		else:
			for x in range(2, n):
				if n % x == 0:
					return False
			return True

	def gcd(self, a, b):
		if b == 0:
			return a
		return self.gcd(b, a % b)

	def lcm(self, a, b):
		return a * b // self.gcd(a, b)

	def mul(self, A, B):
		ans = []
		for a in A:
			c = 0
			for (j, row) in enumerate(a):
				c += row * B[j]
			ans.append(c)
		return ans
mymath = mymath()

class output:

	def list(self, l):
		l = list(l)
		for (i, num) in enumerate(l):
			print(num, end='')
			if i != len(l) - 1:
				print(' ', end='')
		print()
output = output()

def printA(A):
	N = len(A)
	for (i, n) in enumerate(A):
		print(n, end='')
		if i != N - 1:
			print(' ', end='')
	print()

def is_integer(n):
	try:
		float(n)
	except ValueError:
		return False
	else:
		return float(n).is_integer()

def dist(A, B):
	d = 0
	for i in range(len(A)):
		d += (A[i] - B[i]) ** 2
	d = d ** (1 / 2)
	return d

def get_input():
	N = []
	while True:
		try:
			N.append(input())
		except EOFError:
			break
	return N
while True:
	(N, M) = [int(x) for x in input().split()]
	if N == 0 and M == 0:
		break
	P = []
	for i in range(M):
		P.append([int(x) for x in input().split()])
	A = []
	for i in range(N):
		temp = 0
		for j in range(M):
			temp += P[j][i]
		A.append(temp)
	print(max(A))


import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys

def main():
	while True:
		(N, M) = read_ints()
		if (N, M) == (0, 0):
			break
		P = [read_ints() for _ in range(M)]
		print(solve(N, M, P))

def solve(N, M, P):
	T = [[P[j][i] for j in range(M)] for i in range(N)]
	return max([sum(t) for t in T])
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


while True:
	a = list(map(int, input().split()))
	if a[0] == 0:
		break
	else:
		max_sum = 0
		s = 0
		table = []
		for i in range(a[1]):
			table.append(list(map(int, input().split())))
		for i in range(a[0]):
			s = 0
			for j in range(a[1]):
				s += table[j][i]
			max_sum = max(s, max_sum)
		print(max_sum)


def main():
	import sys
	from itertools import chain
	while True:
		(n, m) = map(int, sys.stdin.readline().split())
		if n == m == 0:
			break
		A = list(chain.from_iterable((map(int, sys.stdin.readline().split()) for _ in range(m))))
		ans = 0
		for i in range(n):
			sm = sum(A[i::n])
			if ans < sm:
				ans = sm
		print(ans)
main()