Transform to Chessboard
Transform an n×n binary matrix into an alternating chessboard pattern using only row-wise and column-wise swaps. Return the minimum number of swaps, or -1 if impossible. A valid board requires each row and column to have exactly half 0s and half 1s.