#include<iostream>
using namespace std;
int n, m, ok=0;
int a[100];
void ktao()
{
for(int i=1;i<=m;++i)
{
a[i]=0;
}
}
void sinh()
{
int i=m;
while(i>=1&&a[i]==1)
{
a[i]=0;
--i;
}
if(i==0) ok=1;
else a[i]=1;
}
int count(int rented[], int n)
{
int sum=0;
for(int i=1;i<=n;++i) if (rented[i]) sum++;
return sum;
}
int main()
{
cin>>m>>n;
int k[m+1][n+1];
for(int i=1;i<=m;++i)
{
for(int j=1;j<=n;++j) cin>>k[i][j];
}
int ans[100][100];
int max=0, dem=0;
ktao();
int rented[n+1];
while(!ok)
{
sinh();
for(int i=1;i<=n;++i) rented[i]=0;
bool valid=true;
for(int i=1;i<=m;++i)
{
if(a[i])
{
for(int j=1;j<=n;++j)
{
if (k[i][j]&&rented[j]==0) rented[j]=1;
else if(k[i][j]&&rented[j]==1)
{
valid=false;
break;
}
}
}
if(!valid) break;
}
if (valid)
{
int v=count(rented,n);
if(v>max)
{
dem=1;
max=v;
for(int i=1;i<=m;++i)
{
ans[dem][i]=a[i];
}
}
else if (v==max)
{
dem++;
for(int i=1;i<=m;++i)
{
ans[dem][i]=a[i];
}
}
}
}
for(int i=1;i<=dem;++i)
{
for(int j=1;j<=m;++j) cout<<ans[i][j]<<" ";
cout<<endl;
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sIG0sIG9rPTA7CmludCBhWzEwMF07Cgp2b2lkIGt0YW8oKQp7CiAgICBmb3IoaW50IGk9MTtpPD1tOysraSkKICAgIHsKICAgICAgICBhW2ldPTA7CiAgICB9Cn0KCnZvaWQgc2luaCgpCnsKICAgIGludCBpPW07CiAgICB3aGlsZShpPj0xJiZhW2ldPT0xKQogICAgewogICAgICAgIGFbaV09MDsKICAgICAgICAtLWk7CiAgICB9CiAgICBpZihpPT0wKSBvaz0xOwogICAgZWxzZSBhW2ldPTE7Cn0KCmludCBjb3VudChpbnQgcmVudGVkW10sIGludCBuKQp7CiAgICBpbnQgc3VtPTA7CiAgICBmb3IoaW50IGk9MTtpPD1uOysraSkgaWYgKHJlbnRlZFtpXSkgc3VtKys7CiAgICByZXR1cm4gc3VtOwp9CgppbnQgbWFpbigpCnsKICAgIGNpbj4+bT4+bjsKICAgIGludCBrW20rMV1bbisxXTsKICAgIGZvcihpbnQgaT0xO2k8PW07KytpKQogICAgewogICAgICAgIGZvcihpbnQgaj0xO2o8PW47KytqKSBjaW4+PmtbaV1bal07CiAgICB9CiAgICBpbnQgYW5zWzEwMF1bMTAwXTsKICAgIGludCBtYXg9MCwgZGVtPTA7CiAgICBrdGFvKCk7CiAgICBpbnQgcmVudGVkW24rMV07CiAgICB3aGlsZSghb2spCiAgICB7CiAgICAgICAgc2luaCgpOwogICAgICAgIGZvcihpbnQgaT0xO2k8PW47KytpKSByZW50ZWRbaV09MDsKICAgICAgICBib29sIHZhbGlkPXRydWU7CiAgICAgICAgZm9yKGludCBpPTE7aTw9bTsrK2kpCiAgICAgICAgewogICAgICAgICAgICBpZihhW2ldKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3IoaW50IGo9MTtqPD1uOysraikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoa1tpXVtqXSYmcmVudGVkW2pdPT0wKSByZW50ZWRbal09MTsKICAgICAgICAgICAgICAgICAgICBlbHNlIGlmKGtbaV1bal0mJnJlbnRlZFtqXT09MSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbGlkPWZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoIXZhbGlkKSBicmVhazsKICAgICAgICB9CiAgICAgICAgaWYgKHZhbGlkKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHY9Y291bnQocmVudGVkLG4pOwogICAgICAgICAgICBpZih2Pm1heCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZGVtPTE7CiAgICAgICAgICAgICAgICBtYXg9djsKICAgICAgICAgICAgICAgIGZvcihpbnQgaT0xO2k8PW07KytpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGFuc1tkZW1dW2ldPWFbaV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAodj09bWF4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkZW0rKzsKICAgICAgICAgICAgICAgIGZvcihpbnQgaT0xO2k8PW07KytpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGFuc1tkZW1dW2ldPWFbaV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9ICAgIAogICAgfQogICAgZm9yKGludCBpPTE7aTw9ZGVtOysraSkKICAgIHsKICAgICAgICBmb3IoaW50IGo9MTtqPD1tOysraikgY291dDw8YW5zW2ldW2pdPDwiICI7CiAgICAgICAgY291dDw8ZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9
MTAKMjAKMCAwIDAgMCAxIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDEgMCAwCjAgMSAwIDEgMCAwIDAgMCAwIDAgMCAxIDAgMSAwIDAgMCAwIDAgMAoxIDAgMCAwIDAgMSAwIDAgMCAwIDAgMCAwIDAgMSAwIDAgMSAwIDAKMCAwIDEgMCAwIDAgMCAwIDAgMSAwIDAgMCAwIDAgMCAwIDAgMSAwCjAgMSAxIDEgMCAwIDAgMCAwIDAgMCAwIDAgMCAxIDAgMCAwIDAgMAowIDAgMCAwIDAgMCAxIDAgMCAwIDAgMCAwIDAgMCAxIDAgMCAwIDAKMCAwIDAgMCAwIDEgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMSAwCjAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDEgMCAwIDAgMCAwI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