```go
package main
import (
"bufio"
"fmt"
"os"
"sort"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, m int
if _, err := fmt.Fscan(reader, &n, &m); err != nil {
return
}
grid := make([]string, n)
for i := 0; i < n; i++ {
fmt.Fscan(reader, &grid[i])
}
numEven := (m + 1) / 2
numOdd := m / 2
cost := make([][2][26]int, n)
for i := 0; i < n; i++ {
cnt := [2][26]int{}
for j := 0; j < m; j++ {
c := grid[i][j] - 'a'
if j%2 == 0 {
cnt[0][c]++
} else {
cnt[1][c]++
}
}
for c := 0; c < 26; c++ {
cost[i][0][c] = numEven - cnt[0][c]
cost[i][1][c] = numOdd - cnt[1][c]
}
}
const INF = 1000000000
dp := make([][26][26]int, n)
parent := make([][26][26][2]int, n)
for x := 0; x < 26; x++ {
for y := 0; y < 26; y++ {
if x == y {
dp[0][x][y] = INF
} else {
dp[0][x][y] = cost[0][0][x] + cost[0][1][y]
}
}
}
type Entry struct {
val, x, y int
}
sortedPrev := make([]Entry, 0, 26*26)
for i := 1; i < n; i++ {
sortedPrev = sortedPrev[:0]
for px := 0; px < 26; px++ {
for py := 0; py < 26; py++ {
if dp[i-1][px][py] < INF {
sortedPrev = append(sortedPrev, Entry{dp[i-1][px][py], px, py})
}
}
}
sort.Slice(sortedPrev, func(a, b int) bool {
return sortedPrev[a].val < sortedPrev[b].val
})
for x := 0; x < 26; x++ {
for y := 0; y < 26; y++ {
if x == y {
dp[i][x][y] = INF
continue
}
currentCost := cost[i][0][x] + cost[i][1][y]
bestPrev := INF
var bestPx, bestPy int
for _, p := range sortedPrev {
if p.x != x && p.y != y {
bestPrev = p.val
bestPx = p.x
bestPy = p.y
break
}
}
if bestPrev != INF {
dp[i][x][y] = bestPrev + currentCost
parent[i][x][y] = [2]int{bestPx, bestPy}
} else {
dp[i][x][y] = INF
}
}
}
}
ans := INF
var ax, ay int
for x := 0; x < 26; x++ {
for y := 0; y < 26; y++ {
if dp[n-1][x][y] < ans {
ans = dp[n-1][x][y]
ax, ay = x, y
}
}
}
fmt.Fprintln(writer, ans)
res := make([][2]int, n)
currX, currY := ax, ay
for i := n - 1; i >= 0; i-- {
res[i] = [2]int{currX, currY}
if i > 0 {
p := parent[i][currX][currY]
currX, currY = p[0], p[1]
}
}
for i := 0; i < n; i++ {
cx, cy := res[i][0], res[i][1]
for j := 0; j < m; j++ {
if j%2 == 0 {
writer.WriteByte(byte('a' + cx))
} else {
writer.WriteByte(byte('a' + cy))
}
}
writer.WriteByte('\n')
}
}
```