#include<iostream>
using namespace std;

int main()
{
int car,car2,carica,carica2,of,of2,kon,kon2,top,top2,pesh,pesh2,ost1,ost2,ost3,ost4,ost5,ost6,ost7,ost8,ost9,ost10,ost11,ost12;
cin>>car>>carica>>of>>kon>>top>>pesh;
cin>>car2>>carica2>>of2>>kon2>>top2>>pesh2;
if(car!=2){
ost1=2%car;
}
else
{
ost1=0;
}
if(car!=2){
ost1=2%car;
}
else
{
ost1=0;
}
if(car2!=2){
ost7=2%car2;
}
else
{
ost7=0;
}
if(carica!=2){
ost2=2%carica;
}
else
{
ost2=0;
}
if(carica2!=2){
ost8=2%carica2;
}
else
{
ost8=0;
}
if(of!=2){
ost3=2%of;
}
else
{
ost3=0;
}
if(of2!=2){
ost9=2%of2;
}
else
{
ost9=0;
}
if(kon!=2){
ost4=2%kon;
}
else
{
ost4=0;
}
if(kon2!=2){
ost10=2%kon2;
}
else
{
ost10=0;
}
if(top!=2){
ost5=2%top;
}
else
{
ost5=0;
}
if(top2!=2){
ost11=2%top2;
}
else
{
ost11=0;
}
if(pesh!=8){
ost6=8%pesh;
}
else
{
ost6=0;
}
if(pesh2!=8){
ost12=8%pesh2;
}
else
{
ost12=0;
}
cout<<ost1<<' '<<ost2<<' '<<ost3<<' '<<ost4<<' '<<ost5<<' '<<ost6<<endl;
cout<<ost7<<' '<<ost8<<' '<<ost9<<' '<<ost10<<' '<<ost11<<' '<<ost12<<endl;
}
