#include <iostream>
using namespace std;
int main(){
    long long carb,carib,topb,konb,ofib,peshb,carch,carich,topch,konch,ofich,peshch;
    cin>>carb>>carib>>topb>>konb>>ofib>>peshb>>carch>>carich>>topch>>konch>>ofich>>peshch;
    carb=1-carb;
    carib=1-carib;
    topb=2-topb;
    konb=2-konb;
    ofib=2-ofib;
    peshb=8-peshb;
    carch=1-carch;
    carich=1-carich;
    topch=2-topch;
    konch=2-konch;
    ofich=2-ofich;
    peshch=8-peshch;
    cout<<carb<<" "<<carib<<" "<<topb<<" "<<konb<<" "<<ofib<<" "<<peshb<<endl<<carch<<" "<<carich<<" "<<topch<<" "<<konch<<" "<<ofich<<" "<<peshch;
    return 0;
}

