#include <iostream>
#include <cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1001001001;

int N;
int map[12][12];

int main(){
    std::cin >> N;

    REP(_, N){
        FOR(i, 1, 11){
            FOR(j, 1, 11){
                std::cin >> map[i][j];
            }
        }

        FOR(i, 1, 11){
            FOR(j, 1, 11){
                if(map[i-1][j] == 1 && map[i][j-1] == 1){
                    printf("1");
                    map[i][j] = !map[i][j];
                    map[i+1][j] = !map[i+1][j];
                    map[i][j+1] = !map[i][j+1];
                }else{
                    printf("0");
                }
                
                if(j < 10){printf(" ");}
                else{puts("");}
            }
        }
    }
}