# include <iostream>
# include <cstring>
using namespace std;
const int ROW = 5 ;
const int COL = 6 ;
void change ( char lamp[ ] , int row, int col) {
if ( row >= 0 && row < ROW && col >= 0 && col < COL)
lamp[ row] ^= ( 1 << col) ;
}
void press ( char lamp[ ] , int row, int col) {
change ( lamp, row, col) ;
change ( lamp, row- 1 , col) ;
change ( lamp, row+ 1 , col) ;
change ( lamp, row, col- 1 ) ;
change ( lamp, row, col+ 1 ) ;
}
void pressline ( char lamp[ ] , int row, int bits) {
for ( int i = 0 ; i < COL; i++ )
if ( ( 1 << i) & bits)
press ( lamp, row, i) ;
}
void input ( char lamp[ ] ) {
for ( int i = 0 ; i < ROW; i++ ) {
lamp[ i] = 0 ;
for ( int j = 0 ; j < COL; j++ ) {
int n;
cin >> n;
if ( n)
lamp[ i] |= 1 << j;
}
}
}
void output ( char state[ ] ) {
for ( int i = 0 ; i < ROW; i++ ) {
for ( int j = 0 ; j < COL; j++ )
if ( state[ i] & ( 1 << j) )
cout << "1 " ;
else
cout << "0 " ;
cout << endl;
}
}
void separator ( char ch) {
for ( int i = 0 ; i < COL * 2 - 1 ; i++ )
cout << ch;
cout << endl;
}
void process ( char lamp[ ] , char turn[ ] ) {
char light[ ROW] ;
memcpy ( light, lamp, sizeof ( char ) * ROW) ;
for ( int i = 0 ; i < ROW; i++ ) {
pressline ( light, i, turn[ i] ) ;
separator ( '-' ) ;
output ( light) ;
}
}
bool solve ( char lamp[ ] , char turn[ ] ) {
for ( int i = 0 ; i < ( 1 << COL) ; i++ ) {
char light[ ROW] ;
memcpy ( light, lamp, sizeof ( char ) * ROW) ;
turn[ 0 ] = i;
pressline ( light, 0 , i) ;
for ( int j = 1 ; j < ROW; j++ ) {
turn[ j] = light[ j- 1 ] ;
pressline ( light, j, turn[ j] ) ;
}
if ( light[ ROW- 1 ] == 0 )
return true ;
}
return false ;
}
int main ( ) {
char lamp[ ROW] ;
char turn[ ROW] ;
freopen ( "熄灯问题.in" , "r" , stdin ) ;
input ( lamp) ;
output ( lamp) ;
solve ( lamp, turn) ;
# ifdef DEBUG
process ( lamp, turn) ;
# endif
separator ( '=' ) ;
output ( turn) ;
return 0 ;
}