#include <iostream>
#define FIN "graphcoloring.in"
#define FOUT "graphcoloring.out"
#define DIM 100
using namespace std;
int matrix[ DIM ][ DIM ],
colors [ DIM ],
countries, color, ok;
int main(int argc, char const *argv[]) {
//freopen(FIN, "r", stdin);
cin>>countries;
for(int i = 0; i < countries; ++i) {
for(int j = 0; j < countries; ++j) {
cin>>matrix[i][j];
}
}
for(int i = 0; i < countries; ++i) {
for(int j = 0; j < countries; ++j) {
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
colors[0] = 0;
for(int i = 1; i < countries; ++i) {
color = -1;
do {
color++;
ok = 1;
for(int k = 0; k < i && ok; ++k) {
if(matrix[ k ][ i ] == 1 && colors[ k ] == color) ok = 0;
}
} while(!ok);
colors[i] = color;
}
for(int i = 0; i < countries; ++i) cout<<colors[i]+1<<" ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojZGVmaW5lIEZJTiAiZ3JhcGhjb2xvcmluZy5pbiIKI2RlZmluZSBGT1VUICJncmFwaGNvbG9yaW5nLm91dCIKI2RlZmluZSBESU0gMTAwCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1hdHJpeFsgRElNIF1bIERJTSBdLAogICAgY29sb3JzIFsgRElNIF0sCiAgICBjb3VudHJpZXMsIGNvbG9yLCBvazsKCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0ICphcmd2W10pIHsKCiAgLy9mcmVvcGVuKEZJTiwgInIiLCBzdGRpbik7CgogIGNpbj4+Y291bnRyaWVzOwoKICBmb3IoaW50IGkgPSAwOyBpIDwgY291bnRyaWVzOyArK2kpIHsKICAgICAgZm9yKGludCBqID0gMDsgaiA8IGNvdW50cmllczsgKytqKSB7CiAgICAgICAgICBjaW4+Pm1hdHJpeFtpXVtqXTsKICAgICAgfQogIH0KCiAgZm9yKGludCBpID0gMDsgaSA8IGNvdW50cmllczsgKytpKSB7CiAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBjb3VudHJpZXM7ICsraikgewogICAgICAgICAgY291dDw8bWF0cml4W2ldW2pdPDwiICI7CiAgICAgIH0KICAgICAgY291dDw8ZW5kbDsKICB9CgogIGNvbG9yc1swXSA9IDA7CgoKICBmb3IoaW50IGkgPSAxOyBpIDwgY291bnRyaWVzOyArK2kpIHsKCiAgICBjb2xvciA9IC0xOwoKICAgIGRvIHsKCiAgICAgICBjb2xvcisrOwoKICAgICAgIG9rID0gMTsKCiAgICAgICBmb3IoaW50IGsgPSAwOyBrIDwgaSAmJiBvazsgKytrKSB7CgogICAgICAgICAgIGlmKG1hdHJpeFsgayBdWyBpIF0gPT0gMSAmJiBjb2xvcnNbIGsgXSA9PSBjb2xvcikgb2sgPSAwOwoKICAgICAgIH0KCiAgICB9IHdoaWxlKCFvayk7CgogICAgY29sb3JzW2ldID0gY29sb3I7CgogIH0KCiAgZm9yKGludCBpID0gMDsgaSA8IGNvdW50cmllczsgKytpKSBjb3V0PDxjb2xvcnNbaV0rMTw8IiAiOwoKICByZXR1cm4gMDsKfQ==