#include <bits/stdc++.h>
using namespace std;
int n,m,sum,arr[25];
int main(){
cin >> n >>m;
for (int i=0;i<n;i++){
int Max=0;
for(int j=0,tmp;j<m;j++){
cin >> tmp;
Max=max(Max,tmp);
}
arr[i]=Max;
sum+=Max;
}
cout << sum <<'\n';
bool found = false;
for(int i=0;i<n;i++){
if(sum%arr[i]==0){
if(found) cout << ' ';
else found=true;
cout << arr[i];
}
}
if(!found){
cout << "-1" <<'\n';
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n,m,sum,arr[25];
int main(){
cin >> n >>m;
for (int i=0;i<n;i++){
int Max=0;
for(int j=0,tmp;j<m;j++){
cin >> tmp;
Max=max(Max,tmp);
}
arr[i]=Max;
sum+=Max;
}
cout << sum <<'\n';
bool found = false;
for(int i=0;i<n;i++){
if(sum%arr[i]==0){
if(found) cout << ' ';
else found=true;
cout << arr[i];
}
}
if(!found){
cout << "-1" <<'\n';
}
return 0;
}
sum沒有初始化