#include<iostream>
#include<array>
#include<algorithm>
#include<cmath>
#include<vector>
#include<bitset>
#include<stack>
using namespace std;
using gg=long long;
struct node{
bitset<510> val;
gg rank;
};
vector<node> block;
bitset<510> flag;
gg n,m;
stack<gg> ans;
inline bool cmp1(const node &a,const node &b)
{
return a.val.count()>b.val.count();
}
inline bool cmp2(const node &a,const node &b)
{
for(register gg i=1;i<=m;i++)
{
if(a.val[i]&&(!b.val[i]))
{
return true;
}
if((!a.val[i])&&b.val[i])
{
return false;
}
}
return true;
}
int main()
{
cin>>n>>m;
bool input;
register gg p=0,fp=1;
for(register gg i=1;i<=n;i++)
{
node shuru;
shuru.rank=i;
for(register gg j=1;j<=m;j++)
{
cin>>input;
shuru.val[j]=input;
}
block.push_back(shuru);
}
sort(block.begin(),block.end(),cmp1);
while(block[p].val.count()>1&&p<n)
{
p++;
}
sort(block.begin()+p,block.end(),cmp2);
for(register gg i=1;i<=m;i++)
{
if(block[p].val[i])
{
fp=i;
break;
}
}
for(register gg i=p;i<n;i++)
{
if(block[i].val[fp-1])
{
continue;
}
for(gg j=fp;j<=m;j++)
{
if(block[i].val[j])
{
fp=j+1;
ans.push(block[i].rank);
}
}
}
if(ans.empty())
{
cout<<"No Solution!\n";
}
else
{
while(!ans.empty())
{
cout<<ans.top()<<' ';
ans.pop();
}
cout<<'\n';
}
return 0;
}
暴力哪错了