#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 7;
bool win[7][7]= {
{0, 0, 1, 1, 1, 0, 1},
{1, 0, 1, 1, 1, 1, 1},
{0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{1, 0, 1, 1, 1, 0, 1},
{0, 0, 1, 1, 1, 0, 0}
};
bool compare(int i, int j) {
return win[i][j];
}
int main() {
vector<int> res(N);
for (int i=0; i<N; i++)
res[i] = i;
sort(res.begin(), res.end(), compare);
for(auto v: res)
cout << v << " ";
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSA3Owpib29sIHdpbls3XVs3XT0gewogezAsIDAsIDEsIDEsIDEsIDAsIDF9LAogezEsIDAsIDEsIDEsIDEsIDEsIDF9LAogezAsIDAsIDAsIDEsIDEsIDAsIDB9LAogezAsIDAsIDAsIDAsIDEsIDAsIDB9LAogezAsIDAsIDAsIDAsIDAsIDAsIDB9LAogezEsIDAsIDEsIDEsIDEsIDAsIDF9LAogezAsIDAsIDEsIDEsIDEsIDAsIDB9CiB9OwogCmJvb2wgY29tcGFyZShpbnQgaSwgaW50IGopIHsKCXJldHVybiB3aW5baV1bal07Cn0KCmludCBtYWluKCkgewogICAgdmVjdG9yPGludD4gcmVzKE4pOwogICAgZm9yIChpbnQgaT0wOyBpPE47IGkrKykKICAgIAlyZXNbaV0gPSBpOwogICAgCiAgICBzb3J0KHJlcy5iZWdpbigpLCByZXMuZW5kKCksIGNvbXBhcmUpOwogICAgCiAgICBmb3IoYXV0byB2OiByZXMpCiAgICAgICAgY291dCA8PCB2IDw8ICIgIjsKICAgIGNvdXQgPDwgZW5kbDsKICAgIAogICAgcmV0dXJuIDA7Cn0=