Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)
var (
	table, ans = [12][12]int{}, [12][12]int{}
)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		for j := 1; j < 11; j++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			tmp := [10]int{}
			for k := range input {
				tmp[k], _ = strconv.Atoi(input[k])
			}
			for l := 1; l < 11; l++ {
				table[j][l] = tmp[l-1]
			}
		}
		check(table, 1, ans)
	}
}

func check(table [12][12]int, i int, ans [12][12]int) {
	if i == 11 {
		solve(table, 2, 1, ans)
		return
	}
	ans[1][i] = 0
	check(table, i+1, ans)
	ans[1][i] = 1
	attack(table, 1, i)
	check(table, i+1, ans)
	attack(table, 1, i)
}

func solve(table [12][12]int, i, j int, ans [12][12]int) {
	if i == 11 {
		flag := true
		for k := 1; k < 11; k++ {
			if table[10][k] == 1 {
				flag = false
				break
			}
		}
		if flag {
			printans(ans)
		}
		return
	}
	if table[i-1][j] == 1 {
		ans[i][j] = 1
		attack(table, i, j)
		if j == 10 {
			solve(table, i+1, 1, ans)
		} else {
			solve(table, i, j+1, ans)
		}
		attack(table, i, j)
		ans[i][j] = 0
	} else {
		ans[i][j] = 0
		if j == 10 {
			solve(table, i+1, 1, ans)
		} else {
			solve(table, i, j+1, ans)
		}
	}
}

func printans(ans [12][12]int) {
	for i := 1; i < 11; i++ {
		for j := 1; j < 11; j++ {
			fmt.Print(ans[i][j])
			if j < 10 {
				fmt.Print(" ")
			}
		}
		fmt.Println()
	}
}

func attack(table [12][12]int, i, j int) {
	table[i][j] = 1 - table[i][j]
	table[i-1][j] = 1 - table[i-1][j]
	table[i+1][j] = 1 - table[i+1][j]
	table[i][j-1] = 1 - table[i][j-1]
	table[i][j+1] = 1 - table[i][j+1]
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>

#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];
bool used[12][12];

int reverse(int x, int y){
    map[y][x] = !map[y][x];
    map[y][x-1] = !map[y][x-1];
    map[y-1][x] = !map[y-1][x];
    map[y][x+1] = !map[y][x+1];
    map[y+1][x] = !map[y+1][x];
}

int main(){
    scanf("%d", &N);

    REP(_, N){
        FOR(i, 1, 11){
            FOR(j, 1, 11){
                scanf("%d", &map[i][j]);
            }
        }

        REP(state, 1<<10){
            memset(used, 0, sizeof(used));

            FOR(i, 1, 11){
                if(state >> (i-1) & 1){
                    used[1][i] = true;
                    reverse(i, 1);
                }
            }

            FOR(i, 2, 11){
                FOR(j, 1, 11){
                    if(map[i-1][j] == 1){
                        used[i][j] = true;
                        reverse(j, i);
                    }
                }
            }

            bool f = false;
            FOR(i, 1, 11){
                f |= map[10][i];
            }

            if(f){
                FOR(i, 1, 11){
                    FOR(j, 1, 11){
                        if(used[i][j]){reverse(j, i);}
                    }
                }
                continue;
            }

            FOR(i, 1, 11){
                FOR(j, 1, 11){
                    printf("%d", used[i][j]);
                    if(j < 10){putchar(' ');}
                    else{puts("");}
                }
            } 
        }
    }
}

C++: #include <iostream>
using namespace std;

int field[10][10];
int f2[10][10];
int f3[10][10];

int dx[] = {
	1, 0, -1, 0
};
int dy[] = {
	0, -1, 0, 1
};

bool inside(int x, int y){
	if(x >= 0 && x < 10 && y >= 0 && y < 10)
		return true;
	else return false;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				cin >> field[j][k];
			}
		}
		for(int j = 0; j < 1024; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 10; l++){
					f2[k][l] = field[k][l];
					f3[k][l] = 0;
				}
			}
			for(int k = 0; k < 10; k++){
				if(((j >> k) & 1) == 1){
					for(int l = 0; l < 4; l++){
						if(inside(k + dx[l], dy[l]))
							f2[dy[l]][k+dx[l]] = (f2[dy[l]][k+dx[l]] + 1) % 2;
					}
					f2[0][k] = (f2[0][k] + 1) % 2;
					f3[0][k] = 1;
				}
			}
			for(int k = 1; k < 10; k++){
				for(int l = 0; l < 10; l++){
					if(f2[k-1][l] == 1){
						f3[k][l] = 1;
						for(int m = 0; m < 4; m++){
							if(inside(k + dy[m], l + dx[m]))
								f2[k+dy[m]][l+dx[m]] = (f2[k+dy[m]][l+dx[m]] + 1) % 2;
						}
						f2[k][l] = (f2[k][l] + 1) % 2;
					}
				}
			}
			bool f = true;
			for(int k = 0; k < 10; k++){
				if(f2[9][k] == 1){
					f = false;
					break;
				}
			}
			if(f) break;
		}
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 9; k++){
				cout << f3[j][k] << " ";
			}
			cout << f3[j][9] << endl;
		}

	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int a[10][10],b[10][10],ans[10][10];
int dx[]={1,0,-1,0,0},dy[]={0,1,0,-1,0};

void init(void){
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      b[i][j]=a[i][j];
      ans[i][j]=0;
    }
  }
}

void rev(int x, int y){
  for(int k=0;k<5;k++){

    int ny=y+dy[k],nx=x+dx[k];

    if( 0<=ny && 0<=nx && ny<10 && nx<10)
      b[ny][nx]=!b[ny][nx];
  }
}

int ok(void){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      if(b[i][j])return 0;
  return 1;
}

void solve(int p[]){
  init();

  for(int i=0;i<10;i++){
    if(p[i])rev(i,0);
    ans[0][i]=p[i];
  }
  for(int i=1;i<10;i++){
    for(int j=0;j<10;j++){
      if(b[i-1][j]){
	rev(j,i);
	ans[i][j]=1;
      }
    }
  }

  if(ok()){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	cout << ans[i][j];
	if(j<9)cout << " ";
      }
      cout << endl;
    }
  }
}

void func(int p[], int cnt){
  if(9<cnt)solve(p);
  else {
    p[cnt]=0;
    func(p,cnt+1);
    p[cnt]=1;
    func(p,cnt+1);
  }
}

int main(void){
  int n;

  cin >> n;

  while(n--){

    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
	cin >> a[i][j];

    int p[10]={0};
    func(p,0);
  }

  return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
#include<sstream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
int dx[5] = {0, 1, 0, -1, 0}, dy[5] = {0, 0, 1, 0, -1};
int fld[10][10];

void Reverse(int x, int y, int cnt[10][10])
{
	for(int i = 0; i < 5; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 <= nx && nx < 10 && 0 <= ny && ny < 10) cnt[ny][nx]++;
	}
}

int main(){
	int N;
	cin >> N;
	for(int c = 0; c < N; c++)
	{
		for(int i = 0; i < 10; i++)
		{
			for(int j = 0; j < 10; j++)
			{
				cin >> fld[i][j];
			}
		}

		bool ans = false;
		int out[10][10];
		for(int p = 0; p < (1 << 10); p++)
		{
			int cnt[10][10] = {};
			for(int i = 0; i < 10; i++)
			{
				out[0][i] = ((p >> i) & 1);
				if(out[0][i] == 1) Reverse(i, 0, cnt);
			}
			for(int i = 0; i < 9; i++)
			{
				for(int j = 0; j < 10; j++)
				{
					if(((fld[i][j] + cnt[i][j]) & 1) == 1)
					{
						out[i + 1][j] = 1;
						Reverse(j, i + 1, cnt);
					}
					else
					{
						out[i + 1][j] = 0;
					}
				}
			}

			ans = true;
			for(int i = 0; i < 10; i++)
			{
				if(((fld[9][i] + cnt[9][i]) & 1) == 1) ans = false;
			}
			if(ans) break;
		}

		for(int i = 0; i < 10; i++)
		{
			printf("%d", out[i][0]);
			for(int j = 1; j < 10; j++)
			{
				printf(" %d", out[i][j]);
			}
			puts("");
		}
	}
	return 0;
}