import sys
a+list(map(int,input().split))
n=a[0]
m=a[1]
candidate=[]
for i in range(N):
row=list(map(intinput().split()))
candidatr.append(max(rows))
print(sum(candidate))
times=0
for i in candidate:
if sum(candidate)%i==0:
print(i<end=" ")
time+=1
if time==0:
print(-1)
eles:
print()