static void flip_color(boolean[][] A, int x, int y) {
		int[][] dir = new int[][] { new int[] { 0, 1 }, new int[] { 0, -1 },
				{ 1, 0 }, new int[] { -1, 0 } };

		boolean color = A[x][y];

		A[x][y] = !A[x][y]; // flips.
		for (int[] d : dir) {
			int nx = x + d[0], ny = y + d[1];
			if (nx >= 0 && nx < A.length && ny >= 0 && ny < A[nx].length
					&& A[nx][ny] == color) {
				flip_color(A, nx, ny);
			}
		}
	}