← Home
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	var s, t string
	if _, err := fmt.Fscan(in, &n); err != nil {
		return
	}
	fmt.Fscan(in, &s)
	fmt.Fscan(in, &t)

	ab := make([]int, 0)
	ba := make([]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == t[i] {
			continue
		}
		if s[i] == 'a' && t[i] == 'b' {
			ab = append(ab, i+1)
		} else if s[i] == 'b' && t[i] == 'a' {
			ba = append(ba, i+1)
		}
	}

	if (len(ab)+len(ba))%2 == 1 {
		fmt.Fprintln(out, -1)
		return
	}

	type Pair struct{ x, y int }
	ops := make([]Pair, 0, len(ab)/2+len(ba)/2+2)

	for i := 0; i+1 < len(ab); i += 2 {
		ops = append(ops, Pair{ab[i], ab[i+1]})
	}
	for i := 0; i+1 < len(ba); i += 2 {
		ops = append(ops, Pair{ba[i], ba[i+1]})
	}
	if len(ab)%2 == 1 && len(ba)%2 == 1 {
		i := ab[len(ab)-1]
		j := ba[len(ba)-1]
		ops = append(ops, Pair{i, i})
		ops = append(ops, Pair{i, j})
	}

	fmt.Fprintln(out, len(ops))
	for _, op := range ops {
		fmt.Fprintln(out, op.x, op.y)
	}
}