#include <iostream>
using namespace std;
int n, p;
int arrHV[5];
int arrNP[5];
int visitedHV[5];
int visitedNP[5];
int arrGhe[61];
int visitedGhe[61];
typedef struct Cua{
int vt, sk;
};
Cua arrCua[5];
int SapXepTrai(int VT, int SK){
int KC = 0;
int L = VT-1;
int R = VT+1;
if(visitedGhe[VT] == 0){
visitedGhe[VT] = 1;
SK--;
KC += 1;
}
while(SK > 0){
while(L>=1){
if(visitedGhe[L] == 1)
L--;
else
break;
}
while(R<=n){
if(visitedGhe[R] == 1)
R++;
else
break;
}
if(R == 0){
while(SK>0){
visitedGhe[L] = 0;
SK--;
KC += (VT - L + 1);
}
}
else if(L == 0){
while(SK>0){
visitedGhe[R] = 0;
SK--;
KC += (R - VT + 1);
}
}
while(L>=1 && R<=n && SK>0){
if((VT - L + 1) < (R - VT + 1)){
visitedGhe[L] = 1;
SK--;
KC += (VT - L + 1);
L--;
}else if((VT - L + 1) > (R - VT + 1)){
visitedGhe[R] = 1;
SK--;
KC += (R - VT + 1);
R++;
}else if((VT - L + 1) == (R - VT + 1)){
visitedGhe[L] = 1;
SK--;
KC += (VT - L + 1);
L--;
}
}
}
return KC;
}
int SapXepPhai(int VT, int SK){
int KC = 0;
int L = VT-1;
int R = VT+1;
if(visitedGhe[VT] == 0){
visitedGhe[VT] = 1;
SK--;
KC += 1;
}
while(SK > 0){
while(L>=1){
if(visitedGhe[L] == 1)
L--;
else
break;
}
while(R<=n){
if(visitedGhe[R] == 1)
R++;
else
break;
}
if(L == 0){
while(SK>0){
visitedGhe[R] = 0;
SK--;
KC += (R - VT + 1);
}
}
else if(R == 0){
while(SK>0){
visitedGhe[L] = 0;
SK--;
KC += (VT - L + 1);
}
}
while(L>=1 && R<=n && SK>0){
if((VT - L + 1) < (R - VT + 1)){
visitedGhe[L] = 1;
SK--;
KC += (VT - L + 1);
L--;
}else if((VT - L + 1) > (R - VT + 1)){
visitedGhe[R] = 1;
SK--;
KC += (R - VT + 1);
R++;
}else if((VT - L + 1) == (R - VT + 1)){
visitedGhe[R] = 1;
SK--;
KC += (R - VT + 1);
R++;
}
}
}
return KC;
}
void NhiPhan(int k){
if(k == 4){
for(int i=1; i<=3; i++){
cout << arrHV[i] << " ";
}
cout << endl;
return;
}
for(int i=0; i<2; i++){
arrHV[k] = i;
NhiPhan(k+1);
}
}
void HoanVi(int k){
if(k==4){
int VT1 = arrCua[arrHV[1]].vt;
int SK1 = arrCua[arrHV[1]].sk;
int VT2 = arrCua[arrHV[2]].vt;
int SK2 = arrCua[arrHV[2]].sk;
int VT3 = arrCua[arrHV[3]].vt;
int SK3 = arrCua[arrHV[3]].sk;
}
for(int i=1; i<=3; i++){
if(visitedHV[i] == false){
visitedHV[i] = true;
arrHV[k] = i;
HoanVi(k+1);
visitedHV[i] = false;
}
}
}
int main(){
cin >> n;
for(int i=1; i<=3; i++){
cin >> arrCua[i].vt >> arrCua[i].sk;
}
NhiPhan(1);
//HoanVi(1);
return 0;
}