N,M=map(int,input().split())
list_=[]
for i in range(N):
list_.append(max([int(x) for x in input().split()]))
sum_=sum(list_)
print(sum_)
list_2=[]
for i in list_:
if sum_%i==0:
list_2.append(i)
if bool(list_2):
print(*list_2)
else:
print(-1)