int n, m, ans = 0 ;
cin >> n >> m;
int temporary,mgroup[20];
for(int i=0;i<n;i++){
mgroup[i]=0;
for(int j=0;j<m;j++){
cin >> temporary;
if(mgroup[i]<temporary){
mgroup[i]=temporary;
}
}
ans+=mgroup[i];
}
cout << ans << endl;int cont=0;
for(int i=0;i<n;i++){
if(ans%mgroup[i]==0){
if(cont==0){cout << mgroup[i];cont++;}
else{cout << " " << mgroup[i];cont++;}
}
}
if(cont==0){cout << "-1" ;}