#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;
}