```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
// Read n
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
// cost0[k] stores the cost to transform the k-th piece (0-indexed)
// into a "Type 0" pattern.
// Type 0 pattern means the top-left cell (0,0) of the piece is 0 (white).
// Since it's a chessboard, cell (i, j) should be (i+j)%2.
cost0 := make([]int, 4)
for k := 0; k < 4; k++ {
currentCost := 0
for i := 0; i < n; i++ {
if !scanner.Scan() {
break
}
row := scanner.Text()
for j := 0; j < n; j++ {
// Determine if the current square needs to be changed for Type 0
// Expected color for Type 0 at (i, j) is '0' if (i+j) is even, '1' if odd.
var expected byte
if (i+j)%2 == 0 {
expected = '0'
} else {
expected = '1'
}
if row[j] != expected {
currentCost++
}
}
}
cost0[k] = currentCost
}
// For a 2n x 2n chessboard with n odd:
// If the top-left quadrant is Type 0:
// TL (0..n-1, 0..n-1) -> Type 0
// TR (0..n-1, n..2n-1) -> Starts at (0, n). Since n is odd, (0+n) is odd.
// Relative (0,0) corresponds to odd parity. Must be Type 1.
// BL (n..2n-1, 0..n-1) -> Starts at (n, 0). Odd parity. Must be Type 1.
// BR (n..2n-1, n..2n-1) -> Starts at (n, n). Even parity. Must be Type 0.
// So we need 2 pieces of Type 0 and 2 pieces of Type 1.
//
// If the top-left quadrant is Type 1:
// TL -> Type 1
// TR -> Type 0
// BL -> Type 0
// BR -> Type 1
// So we need 2 pieces of Type 1 and 2 pieces of Type 0.
//
// In both cases, the requirement is to partition the 4 pieces such that
// 2 are converted to Type 0 and 2 are converted to Type 1.
// The cost to convert to Type 1 is (n*n - cost0[k]).
totalSquares := n * n
minCost := -1
// Iterate over all pairs of pieces to be Type 0 (indices 0..3)
// There are C(4, 2) = 6 pairs.
pairs := [][2]int{
{0, 1}, {0, 2}, {0, 3},
{1, 2}, {1, 3}, {2, 3},
}
for _, p := range pairs {
currentCost := 0
// Create a mask or map for quick lookup of Type 0 assignment
isType0 := 0
isType0 |= (1 << p[0])
isType0 |= (1 << p[1])
for k := 0; k < 4; k++ {
if (isType0>>k)&1 == 1 {
// k assigned to Type 0
currentCost += cost0[k]
} else {
// k assigned to Type 1
currentCost += (totalSquares - cost0[k])
}
}
if minCost == -1 || currentCost < minCost {
minCost = currentCost
}
}
fmt.Println(minCost)
}
```