#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
signed main() {
ios::sync_with_stdio(0);
cin.tie(nullptr);
int n,m; cin>>n>>m;
int vote[n][m];
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
cin>>vote[i][j];
}
}
int count[m]; memset(count,0,sizeof(count));
for(int j=0;j<m;j++) {
for(int i=0;i<n;i++) {
count[j]+=vote[i][j];
}
}
// most/2nd most NO votes for each subset {index + no. of votes)
pii nos1[1<<m];
pii nos2[1<<m];
for(int i=0;i<(1<<m);i++) {
int idx1=0,idx2=0, mx1=0, mx2=0;
for(int j=0;j<n;j++) {
int cnt=0;
for(int k=0;k<m;k++) {
if((i&(1<<k))!=0 && vote[j][k]==0) {
cnt++;
}
}
if(cnt>mx1) {
mx2=mx1;
mx1=cnt;
idx2=idx1;
idx1=j;
}
else if(cnt>mx2) {
idx2=j;
mx2=cnt;
}
}
nos1[i]={idx1,mx1};
nos2[i]={idx2,mx2};
}
/*for(int i=0;i<(1<<m);i++) {
cout<<nos1[i].first<<" "<<nos1[i].second<<"\n";
cout<<nos2[i].first<<" "<<nos2[i].second<<"\n";
cout<<"\n";
}*/
//int ans=0;
int threshold = n/2;
for(int i=0;i<n;i++) {
int mask=0;
int pass=0;
for(int j=0;j<m;j++) {
if(count[j]>=threshold+2)pass++;
else if(vote[i][j]==0 && count[j]==threshold+1)pass++;
else if((vote[i][j]==0 && count[j]==threshold) ||
(vote[i][j]==1 && count[j]==threshold+1)){
mask+=(1<<j);
}
}
if(nos1[mask].first==i) pass+=nos2[mask].second;
else pass+=nos1[mask].second;
cout<<pass<<"\n";
}
//cout<<ans<<"\n";
}