Monocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters "a" and "b". 

Monocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the following operation any number of times: choose an index $pos_1$ in the string $s$, choose an index $pos_2$ in the string $t$, and swap $s_{pos_1}$ with $t_{pos_2}$.

You have to determine the minimum number of operations Monocarp has to perform to make $s$ and $t$ equal, and print any optimal sequence of operations — or say that it is impossible to make these strings equal.


-----Input-----

The first line contains one integer $n$ $(1 \le n \le 2 \cdot 10^{5})$ — the length of $s$ and $t$.

The second line contains one string $s$ consisting of $n$ characters "a" and "b". 

The third line contains one string $t$ consisting of $n$ characters "a" and "b". 


-----Output-----

If it is impossible to make these strings equal, print $-1$.

Otherwise, in the first line print $k$ — the minimum number of operations required to make the strings equal. In each of the next $k$ lines print two integers — the index in the string $s$ and the index in the string $t$ that should be used in the corresponding swap operation. 


-----Examples-----
Input
4
abab
aabb

Output
2
3 3
3 2

Input
1
a
b

Output
-1

Input
8
babbaabb
abababaa

Output
3
2 6
1 3
7 8



-----Note-----

In the first example two operations are enough. For example, you can swap the third letter in $s$ with the third letter in $t$. Then $s = $ "abbb", $t = $ "aaab". Then swap the third letter in $s$ and the second letter in $t$. Then both $s$ and $t$ are equal to "abab".

In the second example it's impossible to make two strings equal.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Constructive algorithms


Solutions:
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = list(inp())
	b = list(inp())
	cnt = {}
	for i in range(n):
		if a[i] not in cnt:
			cnt[a[i]] = 1
		else:
			cnt[a[i]] += 1
		if b[i] not in cnt:
			cnt[b[i]] = 1
		else:
			cnt[b[i]] += 1
	for i in cnt:
		if cnt[i] % 2 == 1:
			print(-1)
			return
	ans = []
	ff = deque([])
	ss = deque([])
	for i in range(n):
		if a[i] == b[i]:
			continue
		if a[i] == 'a' and b[i] == 'b':
			ff.append(i + 1)
		else:
			ss.append(i + 1)
	while len(ff) > 1:
		t1 = ff.popleft()
		t2 = ff.popleft()
		ans.append((t2, t1))
	while len(ss) > 1:
		t1 = ss.popleft()
		t2 = ss.popleft()
		ans.append((t1, t2))
	if len(ff) > 0:
		t1 = ff.popleft()
		t2 = ss.popleft()
		ans.append((t2, t2))
		ans.append((t1, t2))
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])
testcase(1)


n = int(input())
s1 = input()
s2 = input()
dif = 0
s1_a = []
s2_a = []
for idx in range(n):
	if s1[idx] != s2[idx]:
		dif += 1
		if s1[idx] == 'a':
			s1_a.append(idx + 1)
		else:
			s2_a.append(idx + 1)
if dif % 2:
	print(-1)
else:
	print(len(s1_a) // 2 + len(s2_a) // 2 + 2 * (len(s1_a) % 2))
	while len(s1_a) >= 2:
		print(s1_a.pop(), s1_a.pop())
	while len(s2_a) >= 2:
		print(s2_a.pop(), s2_a.pop())
	while s1_a:
		t = s1_a.pop()
		print(t, t)
		print(s2_a.pop(), t)


n = int(input())
s = list(input())
t = list(input())
if (s.count('a') + t.count('a')) % 2 != 0:
	print(-1)
else:
	a = []
	b = []
	for i in range(n):
		if s[i] == 'a' and t[i] == 'b':
			a.append(i)
		elif s[i] == 'b' and t[i] == 'a':
			b.append(i)
	a = a[::-1]
	b = b[::-1]
	ans = []
	while len(a) >= 2:
		ans.append([a.pop() + 1, a.pop() + 1])
	while len(b) >= 2:
		ans.append([b.pop() + 1, b.pop() + 1])
	if a:
		ans.append([a[0] + 1, a[0] + 1])
		ans.append([a[0] + 1, b[0] + 1])
	print(len(ans))
	for x in ans:
		print(*x)


SI = lambda : input()
from collections import Counter
n = int(input())
a = SI()
b = SI()

def solve(n, a, b):
	d = Counter(a) + Counter(b)
	for i in d:
		if d[i] & 1:
			print(-1)
			return
	xa = d[a] // 2
	newa = []
	newb = []
	for i in range(n):
		if a[i] != b[i]:
			newa.append((a[i], i))
			newb.append((b[i], i))
	(a, b) = (newa, newb)
	aux = len(a)
	if aux == 0:
		print(0)
		return
	canta = 0
	for i in a:
		if i[0] == 'a':
			canta += 1
	if canta & 1:
		print(len(a) // 2 + 1)
		print(a[0][1] + 1, a[0][1] + 1)
		(a[0], b[0]) = (b[0], a[0])
	else:
		print(len(a) // 2)
	(lastA, lastB) = (-1, -1)
	for i in range(aux):
		if a[i][0] == 'a':
			if lastA == -1:
				lastA = a[i][1]
			else:
				print(lastA + 1, a[i][1] + 1)
				lastA = -1
		elif lastB == -1:
			lastB = a[i][1]
		else:
			print(lastB + 1, a[i][1] + 1)
			lastB = -1
solve(n, a, b)


def solve():
	n = int(input())
	s = input()
	t = input()
	diff = list()
	for i in range(n):
		if s[i] != t[i]:
			diff.append(i)
	if len(diff) % 2 != 0:
		print(-1)
	else:
		index = 0
		swap = list()
		diff = sorted(diff, key=lambda index: s[index])
		ans = 0
		while index < len(diff):
			real_pos = diff[index]
			next_real_pos = diff[index + 1]
			if s[real_pos] == s[next_real_pos]:
				ans += 1
				swap.append((real_pos + 1, next_real_pos + 1))
			else:
				ans += 2
				swap.append((real_pos + 1, real_pos + 1))
				swap.append((real_pos + 1, next_real_pos + 1))
			index += 2
		print(ans)
		for tp in swap:
			print(tp[0], end=' ')
			print(tp[1])
solve()


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = input().rstrip()
	t = input().rstrip()
	(a, b) = ([], [])
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a' and t[i] == 'b':
				a.append(i + 1)
			else:
				b.append(i + 1)
	if len(a) % 2 and len(b) % 2 == 0 or (len(b) % 2 and len(a) % 2 == 0):
		print(-1)
	else:
		f = len(a) % 2
		print(len(a) // 2 + len(b) // 2 + 2 * f)
		for i in range(0, len(a) - f, 2):
			print(a[i], a[i + 1])
		for i in range(0, len(b) - f, 2):
			print(b[i], b[i + 1])
		if f:
			print(a[-1], a[-1])
			print(a[-1], b[-1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))
n = ii()
s = input()
t = input()
if (s.count('a') + t.count('a')) % 2:
	exit(print(-1))
ab = []
ba = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
r = []
while len(ab) >= 2:
	v = ab.pop()
	u = ab.pop()
	r.append(f'{u} {v}')
while len(ba) >= 2:
	v = ba.pop()
	u = ba.pop()
	r.append(f'{u} {v}')
if len(ab) != len(ba):
	exit(print(-1))
elif len(ab) > 0:
	u = ab[0]
	v = ba[0]
	r.append(f'{u} {u}')
	r.append(f'{u} {v}')
print(len(r))
for i in r:
	print(i)


n = int(input())
s = input()
t = input()
(a, b) = ([], [])
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			a.append(i + 1)
		else:
			b.append(i + 1)
(x, y) = (len(a), len(b))
if x % 2 == y % 2:
	k = (x + y) // 2
	if x % 2 == 1:
		print(k + 1)
		for i in range(0, x - 1, 2):
			print(a[i], a[i + 1])
		for i in range(0, y - 1, 2):
			print(b[i], b[i + 1])
		print(a[-1], a[-1])
		print(a[-1], b[-1])
	else:
		print(k)
		for i in range(0, x - 1, 2):
			print(a[i], a[i + 1])
		for i in range(0, y - 1, 2):
			print(b[i], b[i + 1])
else:
	print('-1')


import math

def allPermutations(string):
	listi = permutations(string)
	for i in list(listi):
		print(''.join(i))
from operator import add
n = int(input())
a = input()
b = input()
list1 = []
list2 = []
for i in range(n):
	if a[i] + b[i] == 'ab':
		list1.append(i + 1)
	if a[i] + b[i] == 'ba':
		list2.append(i + 1)
leng = len(list2) + len(list1)
if leng % 2:
	print(-1)
elif len(list1) % 2:
	print(leng // 2 + 1)
	print(list2[0], list2[0])
	print(list2[0], list1[0])
	list2 = list2[1:] + list1[1:]
	for i in range(0, leng - 2, 2):
		print(list2[i], list2[i + 1])
else:
	print(leng // 2)
	list2 = list2 + list1
	for i in range(0, leng, 2):
		print(list2[i], list2[i + 1])


n = int(input())
a = input()
b = input()
(c, d, l) = ([], [], 0)
for i in range(n):
	if a[i] == b[i]:
		continue
	else:
		k = a[i] + b[i]
		if k == 'ab':
			c.append(i + 1)
		else:
			d.append(i + 1)
(p, q) = (len(c), len(d))
if p > 0 or q > 0:
	if p % 2 == q % 2:
		if p % 2 == 0:
			print(p // 2 + q // 2)
			i = 0
			while i + 2 <= p:
				print(c[i], c[i + 1])
				i = i + 2
			i = 0
			while i + 2 <= q:
				print(d[i], d[i + 1])
				i = i + 2
		else:
			print(p // 2 + q // 2 + 2)
			i = 0
			while i + 2 <= p:
				print(c[i], c[i + 1])
				i = i + 2
			i = 0
			while i + 2 <= q:
				print(d[i], d[i + 1])
				i = i + 2
			print(max(c[p - 1], d[q - 1]), max(c[p - 1], d[q - 1]))
			print(max(c[p - 1], d[q - 1]), min(c[p - 1], d[q - 1]))
	else:
		print(-1)
else:
	print(0)


n = int(input())
s = input()
t = input()
ba = 0
ab = 0
baind = []
abind = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'b':
			ba += 1
			baind.append(i)
		else:
			ab += 1
			abind.append(i)
if (ba + ab) % 2 != 0:
	print('-1')
else:
	hi = 0
	swaps = int(ba / 2) + int(ab / 2)
	if ba % 2 != 0:
		hi = 1
		swaps += 2
	print(swaps)
	for x in range(int(len(abind) / 2)):
		print(abind[2 * x] + 1, abind[2 * x + 1] + 1)
	for x in range(int(len(baind) / 2)):
		print(baind[2 * x] + 1, baind[2 * x + 1] + 1)
	if hi == 1:
		print(abind[len(abind) - 1] + 1, abind[len(abind) - 1] + 1)
		print(abind[len(abind) - 1] + 1, baind[len(baind) - 1] + 1)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(n,) = I()
s = input()
t = input()
ds = {'a': [], 'b': []}
dt = {'a': [], 'b': []}
d = {'ab': [], 'ba': []}
for i in range(n):
	ds[s[i]].append(i)
	dt[t[i]].append(i)
	if s[i] != t[i]:
		d[s[i] + t[i]].append(i)
if (len(d['ab']) + len(d['ba'])) % 2:
	print(-1)
	exit()
ans = []
if len(d['ab']) % 2:
	x = d['ab'][-1]
	y = d['ba'][-1]
	d['ab'].pop()
	d['ba'].pop()
	ans.append([x, x])
	ans.append([x, y])
for i in range(0, len(d['ab']), 2):
	x = d['ab'][i]
	y = d['ab'][i + 1]
	ans.append([x, y])
for i in range(0, len(d['ba']), 2):
	x = d['ba'][i]
	y = d['ba'][i + 1]
	ans.append([x, y])
print(len(ans))
for i in ans:
	print(i[0] + 1, i[1] + 1)


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
n = int(ri())
a = ri()
b = ri()
pos1 = []
pos2 = []
for i in range(n):
	if a[i] != b[i]:
		if a[i] == 'a':
			pos1.append(i)
		else:
			pos2.append(i)
if len(pos1) % 2 != len(pos2) % 2:
	print(-1)
else:
	ans = []
	i = 0
	for i in range(0, len(pos1), 2):
		if i + 1 < len(pos1):
			ans.append([pos1[i] + 1, pos1[i + 1] + 1])
	for i in range(0, len(pos2), 2):
		if i + 1 < len(pos2):
			ans.append([pos2[i] + 1, pos2[i + 1] + 1])
	if len(pos1) % 2 == 1:
		ans.append([pos1[-1] + 1, pos1[-1] + 1])
		ans.append([pos1[-1] + 1, pos2[-1] + 1])
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
str1 = input()
str2 = input()
dct = {'a': [], 'b': []}
count_0 = 0
count_1 = 0
for i in range(n):
	if str1[i] != str2[i]:
		if str1[i] == 'a':
			count_0 += 1
			dct['a'].append(i + 1)
		else:
			count_1 += 1
			dct['b'].append(i + 1)
if (count_0 + count_1) % 2 != 0:
	print(-1)
else:
	count = 0
	ans = []
	if count_0 % 2 != 0:
		count += 2
		ans.append((dct['a'][-1], dct['a'][-1]))
		ans.append((dct['a'][-1], dct['b'][-1]))
		dct['a'].pop()
		dct['b'].pop()
		count_0 -= 1
		count_1 -= 1
	for i in range(0, count_0, 2):
		ans.append((dct['a'][i], dct['a'][i + 1]))
		count += 1
	for i in range(0, count_1, 2):
		ans.append((dct['b'][i], dct['b'][i + 1]))
		count += 1
	print(count)
	for i in ans:
		print(*i)


from collections import defaultdict
n = int(input())
s = input()
t = input()
d = []
for (i, c) in enumerate(s):
	if c != t[i]:
		d.append([c, i + 1])
if len(d) % 2:
	print(-1)
	exit()
locs = defaultdict(list)
for diff in d:
	locs[diff[0]].append(diff[1])
if len(locs['a']) % 2:
	print(len(d) // 2 + 1)
else:
	print(len(d) // 2)
while len(locs['a']) >= 2:
	print(locs['a'].pop(), locs['a'].pop())
while len(locs['b']) >= 2:
	print(locs['b'].pop(), locs['b'].pop())
if locs['a']:
	print(locs['a'][0], locs['a'][0])
	print(locs['a'][0], locs['b'][0])


n = int(input())
s = input()
t = input()
ac = 0
bc = 0
for i in range(n):
	if s[i] == 'a':
		ac += 1
	else:
		bc += 1
	if t[i] == 'a':
		ac += 1
	else:
		bc += 1
if ac % 2 != 0:
	print(-1)
else:
	la = []
	lb = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				la.append(i)
			else:
				lb.append(i)
	c = 0
	ans = []
	if len(la) % 2 == 0:
		for i in range(0, len(la), 2):
			ans.append([la[i], la[i + 1]])
		for i in range(0, len(lb), 2):
			ans.append([lb[i], lb[i + 1]])
	else:
		for i in range(0, len(la) - 1, 2):
			ans.append([la[i], la[i + 1]])
		for i in range(0, len(lb) - 1, 2):
			ans.append([lb[i], lb[i + 1]])
		ans.append([la[len(la) - 1], la[len(la) - 1]])
		ans.append([la[len(la) - 1], lb[len(lb) - 1]])
	n = len(ans)
	print(n)
	for i in range(n):
		print(ans[i][0] + 1, ans[i][1] + 1)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
s = list(input())
t = list(input())
ablist = []
balist = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ablist.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		balist.append(i + 1)
if (len(ablist) + len(balist)) % 2:
	print(-1)
else:
	print((len(ablist) + len(balist)) // 2 + len(ablist) % 2)
	for q in range(1, len(ablist), 2):
		print(ablist[q - 1], ablist[q])
	for q in range(1, len(balist), 2):
		print(balist[q - 1], balist[q])
	if len(ablist) % 2 == 1:
		print(ablist[-1], ablist[-1])
		print(ablist[-1], balist[-1])


n = int(input())
(s, t) = (input(), input())
a = s.count('a') + t.count('a')
if a & 1:
	print('-1')
	exit()
A = [i + 1 for i in range(n) if s[i] != t[i] and t[i] == 'a']
B = [i + 1 for i in range(n) if s[i] != t[i] and t[i] == 'b']
sm = (len(A) + len(B)) // 2
if len(A) % 2 == 1:
	print(sm + 1)
	print(B[-1], B[-1], sep=' ')
	A.append(B.pop())
else:
	print(sm)
while len(A) >= 2:
	print(A.pop(), A.pop(), sep=' ')
while len(B) >= 2:
	print(B.pop(), B.pop(), sep=' ')


def equalize(s, t, n):
	if (s.count('a') + t.count('a')) % 2:
		return -1
	missmatch = {'a': -1, 'b': -1}
	swaps = []
	for i in range(n):
		if s[i] != t[i]:
			j = missmatch[s[i]]
			if j == -1:
				missmatch[s[i]] = i
			else:
				missmatch[s[i]] = -1
				swaps.append((i + 1, j + 1))
	if missmatch['a'] == -1:
		return swaps
	else:
		(i, j) = missmatch.values()
		return swaps + [(i + 1, i + 1), (i + 1, j + 1)]
n = int(input())
s = input()
t = input()
swaps = equalize(s, t, n)
if swaps == -1:
	print(-1)
else:
	print(len(swaps))
	[print(*swap) for swap in swaps]


n = int(input())
l1 = input()
l2 = input()
ab = []
ba = []
for i in range(n):
	if l1[i] != l2[i]:
		if l1[i] == 'a' and l2[i] == 'b':
			ab.append(i)
		elif l1[i] == 'b' and l2[i] == 'a':
			ba.append(i)
cnt = 0
lis = []
if not len(ab) & 1 and len(ab) > 0:
	for i in range(0, len(ab) - 1, 2):
		cnt += 1
		lis.append((ab[i] + 1, ab[i + 1] + 1))
elif len(ab) % 2 == 1 and len(ab) > 1:
	for i in range(0, len(ab) - 1, 2):
		cnt += 1
		lis.append((ab[i] + 1, ab[i + 1] + 1))
if not len(ba) & 1 and len(ba) > 0:
	for i in range(0, len(ba) - 1, 2):
		cnt += 1
		lis.append((ba[i] + 1, ba[i + 1] + 1))
elif len(ba) % 2 == 1 and len(ba) > 1:
	for i in range(0, len(ba) - 1, 2):
		cnt += 1
		lis.append((ba[i] + 1, ba[i + 1] + 1))
if len(ab) % 2 == 0 and len(ba) % 2 == 1:
	print(-1)
	exit()
elif len(ab) % 2 == 1 and len(ba) % 2 == 0:
	print(-1)
	exit()
elif len(ab) % 2 == 1 and len(ba) % 2 == 1:
	cnt += 2
	lis.append((ab[-1] + 1, ab[-1] + 1))
	lis.append((ab[-1] + 1, ba[-1] + 1))
print(cnt)
for i in lis:
	print(*i)


n = int(input())
s = input()
t = input()
a = []
for (i, j) in zip(s, t):
	if i + j == 'ab':
		a.append(1)
	elif i + j == 'ba':
		a.append(2)
	else:
		a.append(0)
if n - a.count(0) & 1:
	print(-1)
	exit()
print((a.count(1) + 1) // 2 + (a.count(2) + 1) // 2)
(o, t) = ([], [])
for i in range(n):
	if a[i] == 1:
		o.append(i + 1)
	if a[i] == 2:
		t.append(i + 1)
while len(o) > 1:
	print(o[-1], o[-2])
	del o[-1]
	del o[-1]
while len(t) > 1:
	print(t[-1], t[-2])
	del t[-1]
	del t[-1]
if o and t:
	print(o[0], o[0])
	print(o[0], t[0])


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	n = int(input())
	s = sin()
	d = sin()
	co = 0
	f = {}
	for i in range(n):
		if s[i] == d[i]:
			continue
		e = s[i] + '-' + d[i]
		if e not in f:
			f[e] = [i + 1]
		else:
			f[e].append(i + 1)
	ans = []
	for i in range(n):
		if s[i] == d[i]:
			continue
		e = s[i] + '-' + d[i]
		ee = d[i] + '-' + s[i]
		x = []
		if len(f[e]) == 0:
			continue
		if len(f[e]) > 1:
			x = []
			x.append(f[e].pop())
			x.append(f[e].pop())
			ans.append(x[:])
		elif ee in f and len(f[ee]) > 0:
			x = []
			kkk = f[ee].pop()
			x.append(kkk)
			x.append(kkk)
			ans.append(x[:])
			x.pop()
			x.append(f[e].pop())
			ans.append(x[:])
		else:
			co = -1
			break
	if co == -1:
		print(-1)
	else:
		print(len(ans))
		for i in ans:
			print(*i)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
s1 = input()
s2 = input()
if (s1.count('a') + s2.count('a')) % 2 == 1 or (s1.count('b') + s2.count('b')) % 2 == 1:
	print(-1)
	return
sort1 = []
sort2 = []
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			sort1.append(i)
		else:
			sort2.append(i)
moves = []
while len(sort1) > 1:
	moves.append([sort1[-1], sort1[-2]])
	sort1.pop()
	sort1.pop()
while len(sort2) > 1:
	moves.append([sort2[-1], sort2[-2]])
	sort2.pop()
	sort2.pop()
if len(sort1) == 1:
	moves.append([sort1[0], sort1[0]])
	moves.append([sort1[0], sort2[0]])
print(len(moves))
for x in moves:
	print(x[0] + 1, x[1] + 1)


n = int(input())
word1 = input()
word2 = input()
a = []
b = []
for i in range(n):
	x = word1[i]
	y = word2[i]
	if x == y:
		continue
	if x == 'a':
		a.append(i + 1)
	else:
		b.append(i + 1)
if len(a) % 2 + len(b) % 2 == 1:
	print(-1)
else:
	r = len(a) // 2 + len(b) // 2
	if len(a) % 2 == 1:
		r += 2
	print(r)
	for i in range(1, len(a), 2):
		print(a[i - 1], a[i])
	for i in range(1, len(b), 2):
		print(b[i - 1], b[i])
	if len(a) % 2 == 1:
		print(a[-1], a[-1])
		print(a[-1], b[-1])


N = int(input())
s1 = input()
s2 = input()
abindex = []
baindex = []
for i in range(N):
	if s1[i] == 'a' and s2[i] == 'b':
		abindex.append(i)
		continue
	if s1[i] == 'b' and s2[i] == 'a':
		baindex.append(i)
		continue
length = len(abindex)
length2 = len(baindex)
z = 0
if length % 2 != length2 % 2:
	print(-1)
else:
	if length % 2 == 1 and length2 % 2 == 1:
		x = abindex.pop()
		length -= 1
		baindex.append(x)
		length2 += 1
		z += 1
	print((length + length2) // 2 + z)
	if z == 1:
		print(x + 1, x + 1)
	for i in range(0, length, 2):
		print(abindex[i] + 1, abindex[i + 1] + 1)
	for i in range(0, length2, 2):
		print(baindex[i] + 1, baindex[i + 1] + 1)


def pars(x):
	ans = []
	for i in x:
		if i == 'a':
			ans.append('1')
		else:
			ans.append('0')
	return ans

def strxor(a, b):
	send = bin(int(num1, 2) ^ int(num2, 2))[2:]
	return '0' * (len(a) - len(send)) + send

def pprint(l):
	print(len(l))
	for i in l:
		print(i[0] + 1, i[1] + 1)
n = int(input())
num1 = pars(input())
num2 = pars(input())
ans = []
sh0s = []
sh1s = []
(sh0, sh1) = (0, 0)
for (ind, i) in enumerate(num1):
	if i == '1' and num2[ind] == '0':
		sh0 += 1
		sh0s.append(ind)
	elif i == '0' and num2[ind] == '1':
		sh1 += 1
		sh1s.append(ind)
for i in range(sh0 // 2):
	(num1[sh0s[len(sh0s) - 1]], num2[sh0s[len(sh0s) - 2]]) = (num2[sh0s[len(sh0s) - 2]], num1[sh0s[len(sh0s) - 1]])
	ans.append((sh0s[len(sh0s) - 1], sh0s[len(sh0s) - 2]))
	sh0s.pop()
	sh0s.pop()
for i in range(sh1 // 2):
	(num1[sh1s[len(sh1s) - 1]], num2[sh1s[len(sh1s) - 2]]) = (num2[sh1s[len(sh1s) - 2]], num1[sh1s[len(sh1s) - 1]])
	ans.append((sh1s[len(sh1s) - 1], sh1s[len(sh1s) - 2]))
	sh1s.pop()
	sh1s.pop()
(sh1, sh0) = (sh1 % 2, sh0 % 2)
if sh1 == sh0 and sh0 == 0:
	pprint(ans)
if sh1 != sh0:
	print(-1)
if sh1 == sh0 and sh1 == 1:
	ans.append((sh1s[0], sh1s[0]))
	(num1[sh1s[0]], num2[sh1s[0]]) = (num2[sh1s[0]], num1[sh1s[0]])
	ans.append((sh1s[0], sh0s[0]))
	(num1[sh1s[0]], num2[sh0s[0]]) = (num2[sh1s[0]], num1[sh0s[0]])
	pprint(ans)


n = int(input())
s = input()
t = input()
p = 0
q = 0
pp = []
qq = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		p += 1
		pp.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		q += 1
		qq.append(i + 1)
if p % 2 == 0 and q % 2 == 0:
	ans = str(int(p / 2 + q / 2)) + '\n'
	for j in range(p // 2):
		ans += str(pp.pop()) + ' ' + str(pp.pop()) + '\n'
	for j in range(q // 2):
		ans += str(qq.pop()) + ' ' + str(qq.pop()) + '\n'
	ans = ans.strip()
elif p % 2 == 0 and q % 2 == 1:
	ans = '-1'
elif q % 2 == 0 and p % 2 == 1:
	ans = '-1'
elif p % 2 == 1 and q % 2 == 1:
	ans = str(int(p // 2 + q // 2 + 2)) + '\n'
	for j in range(p // 2):
		ans += str(pp.pop()) + ' ' + str(pp.pop()) + '\n'
	for j in range(q // 2):
		ans += str(qq.pop()) + ' ' + str(qq.pop()) + '\n'
	x = str(pp.pop())
	ans += x + ' ' + x + '\n' + x + ' ' + str(qq.pop())
print(ans)


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list

def sign(x):
	if x > 0:
		return 1
	return -1

def sign1(x, y):
	if x * y > 0:
		return 1
	return -1

def prod(arr):
	val = 1
	for x in arr:
		val *= x
	return val

def main():
	n = int(input())
	x = input()
	y = input()
	ta = x.count('a') + y.count('a')
	tb = x.count('b') + y.count('b')
	if ta & 1 or tb & 1:
		print(-1)
		return
	dict = {}
	dict['ba'] = []
	dict['ab'] = []
	for i in range(n):
		if x[i] == 'a' and y[i] == 'b':
			dict['ba'].append(i + 1)
		elif y[i] == 'a' and x[i] == 'b':
			dict['ab'].append(i + 1)
	farr = []
	if len(dict['ba']) & 1:
		farr.append((dict['ba'][-1], dict['ba'][-1]))
		farr.append((dict['ba'][-1], dict['ab'][-1]))
		dict['ba'].pop()
		dict['ab'].pop()
	lst1 = dict['ba']
	for i in range(0, len(lst1), 2):
		farr.append((lst1[i], lst1[i + 1]))
	lst1 = dict['ab']
	for i in range(0, len(lst1), 2):
		farr.append((lst1[i], lst1[i + 1]))
	print(len(farr))
	for x in farr:
		print(*x)
main()


n = int(input())
sa = []
sb = []
s = str(input())
t = str(input())
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			sa.append(i + 1)
		else:
			sb.append(i + 1)
ad = len(sa) >> 1
bd = len(sb) >> 1
ay = len(sa) - ad * 2
by = len(sb) - bd * 2
j = 0
k = 0
if ay ^ by == 1:
	print(-1)
	exit(0)
elif ay & by == 1:
	print(ad + bd + 2)
else:
	print(ad + bd)
if ay & by == 1:
	print(sa[j], sa[j])
	print(sa[j], sb[k])
	j = j + 1
	k = k + 1
while j < len(sa) or k < len(sb):
	if j < len(sa):
		print(str(sa[j]) + ' ' + str(sa[j + 1]))
		j = j + 2
	if k < len(sb):
		print(str(sb[k]) + ' ' + str(sb[k + 1]))
		k = k + 2


n = int(input())
s = input()
t = input()
d = {}
d['a'] = 0
d['b'] = 0
for i in s:
	d[i] += 1
for i in t:
	d[i] += 1
if d['a'] % 2 == 1 or d['b'] % 2 == 1:
	print(-1)
else:
	ab = []
	ba = []
	for i in range(n):
		if s[i] == 'a' and t[i] == 'b':
			ab.append(i + 1)
		if s[i] == 'b' and t[i] == 'a':
			ba.append(i + 1)
	i = 0
	ope = []
	while i + 2 <= len(ab):
		ope.append([ab[i], ab[i + 1]])
		i += 2
	j = 0
	while j + 2 <= len(ba):
		ope.append([ba[j], ba[j + 1]])
		j += 2
	if i == len(ab):
		print(len(ope))
		for i in ope:
			print(*i)
	else:
		print(len(ope) + 2)
		for i in ope:
			print(*i)
		print(ab[-1], ab[-1])
		print(ba[-1], ab[-1])


n = input()
s1 = input()
s2 = input()
indices_with_ab = []
indices_with_ba = []
for i in range(len(s1)):
	if (s1[i] == 'a') & (s2[i] == 'b'):
		indices_with_ab.append(i)
	elif (s1[i] == 'b') & (s2[i] == 'a'):
		indices_with_ba.append(i)
if (len(indices_with_ab) + len(indices_with_ba)) % 2 == 1:
	print(-1)
	exit()
if len(indices_with_ab) % 2 == 0:
	print(len(indices_with_ab) // 2 + len(indices_with_ba) // 2)
else:
	print(len(indices_with_ab) // 2 + len(indices_with_ba) // 2 + 2)
for i in range(0, len(indices_with_ab) - 1, 2):
	print(f'{indices_with_ab[i] + 1} {indices_with_ab[i + 1] + 1}')
for i in range(0, len(indices_with_ba) - 1, 2):
	print(f'{indices_with_ba[i] + 1} {indices_with_ba[i + 1] + 1}')
if len(indices_with_ab) % 2 != 0:
	print(f'{indices_with_ab[-1] + 1} {indices_with_ab[-1] + 1}')
	print(f'{indices_with_ab[-1] + 1} {indices_with_ba[-1] + 1}')


n = int(input())
x = input()
y = input()
ba = []
ab = []
i = 0
while i < n:
	if x[i] == 'a' and y[i] == 'b':
		ab.append(i + 1)
	elif x[i] == 'b' and y[i] == 'a':
		ba.append(i + 1)
	i += 1
if (len(ab) + len(ba)) % 2 == 1:
	print(-1)
else:
	(i, j) = (0, 0)
	print(len(ab) // 2 + len(ab) % 2 + len(ba) // 2 + len(ba) % 2)
	while i < len(ab) - 1:
		print(ab[i], ab[i + 1])
		i += 2
	while j < len(ba) - 1:
		print(ba[j], ba[j + 1])
		j += 2
	if i < len(ab):
		print(ab[i], ab[i])
		print(ab[i], ba[j])


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
n = int(input())
s = input()
t = input()
a = s.count('a') + t.count('a')
b = s.count('b') + t.count('b')
if a & 1 == 0 and b & 1 == 0:
	ss = []
	sss = []
	ans = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		elif s[i] == 'a' and t[i] == 'b':
			ss.append(i + 1)
		else:
			sss.append(i + 1)
	for i in range(0, len(ss), 2):
		if i + 1 < len(ss):
			ans.append([ss[i], ss[i + 1]])
	for i in range(0, len(sss), 2):
		if i + 1 < len(sss):
			ans.append([sss[i], sss[i + 1]])
	if len(ss) & 1:
		a = ss[-1]
		b = sss[-1]
		ans.append([a, a])
		ans.append([a, b])
	print(len(ans))
	for i in ans:
		print(*i)
else:
	print(-1)


def countchar(s1, s2):
	vala = s1.count('a') + s2.count('a')
	valb = s2.count('b') + s2.count('b')
	if vala % 2 == 0 and valb % 2 == 0:
		return True
	else:
		return False

def calcarr(s1, s2):
	(a2b, b2a) = ([], [])
	sol = []
	for i in range(len(s1)):
		if s1[i] == 'a' and s2[i] == 'b':
			a2b.append(i)
		elif s1[i] == 'b' and s2[i] == 'a':
			b2a.append(i)
	k = 0
	if len(a2b) % 2 == 0 and len(b2a) % 2 == 0:
		for i in range(1, len(a2b), 2):
			sol.append([a2b[i - 1] + 1, a2b[i] + 1])
			k += 1
		for i in range(1, len(b2a), 2):
			sol.append([b2a[i - 1] + 1, b2a[i] + 1])
			k += 1
	else:
		for i in range(1, len(a2b), 2):
			sol.append([a2b[i - 1] + 1, a2b[i] + 1])
			k += 1
		for i in range(1, len(b2a), 2):
			sol.append([b2a[i - 1] + 1, b2a[i] + 1])
			k += 1
		sol.append([a2b[-1] + 1, a2b[-1] + 1])
		sol.append([a2b[-1] + 1, b2a[-1] + 1])
		k += 2
	print(k)
	for i in sol:
		print(i[0], i[1])

def main():
	n = int(input())
	s1 = input()
	s2 = input()
	if countchar(s1, s2):
		calcarr(s1, s2)
	else:
		print('-1')
main()


n = int(input())
s = input()
t = input()
if s == t:
	print(0)
else:
	a = []
	b = []
	c = 0
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				a.append(i + 1)
			else:
				b.append(i + 1)
			c += 1
	if c % 2:
		print(-1)
	else:
		if len(a) % 2:
			print((len(a) + len(b)) // 2 + 1)
		else:
			print((len(a) + len(b)) // 2)
		for i in range(0, len(a) - len(a) % 2, 2):
			print(a[i], a[i + 1])
		for i in range(0, len(b) - len(b) % 2, 2):
			print(b[i], b[i + 1])
		if len(a) % 2 != 0:
			print(a[-1], a[-1])
			print(a[-1], b[-1])


N = int(input())
s = input()
t = input()
sa = []
sb = []
for i in range(N):
	if s[i] == t[i]:
		continue
	if s[i] == 'a':
		sa.append(i + 1)
	if s[i] == 'b':
		sb.append(i + 1)
L = len(sa) + len(sb)
if L & 1:
	print(-1)
else:
	if len(sa) & 1:
		print(L // 2 + 1)
	else:
		print(L // 2)
	while len(sa) >= 2:
		a = sa.pop()
		b = sa.pop()
		print(a, b)
	while len(sb) >= 2:
		a = sb.pop()
		b = sb.pop()
		print(a, b)
	if sa:
		a = sa.pop()
		b = sb.pop()
		print(a, a)
		print(a, b)


from sys import stdin, exit, setrecursionlimit
from math import *
from bisect import bisect_left
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
mod = 10 ** 9 + 7
n = int(input())
a = si()
b = si()
arr = [0, 0]
arr2 = [[], []]
for i in range(n):
	if a[i] != b[i]:
		arr[a[i] == 'a'] += 1
		if a[i] == 'a':
			arr2[0].append(i)
		else:
			arr2[1].append(i)
ans = arr[0] // 2 + arr[1] // 2
if arr[0] % 2 == 1 and arr[1] % 2 == 1:
	ans += 2
elif arr[0] % 2 == 1 or arr[1] % 2 == 1:
	print(-1)
	exit()
print(ans)
for i in range(0, len(arr2[0]) - 1, 2):
	print(arr2[0][i] + 1, arr2[0][i + 1] + 1)
for i in range(0, len(arr2[1]) - 1, 2):
	print(arr2[1][i] + 1, arr2[1][i + 1] + 1)
if arr[0] % 2 == 1 and arr[1] % 2 == 1:
	print(arr2[0][-1] + 1, arr2[0][-1] + 1)
	print(arr2[0][-1] + 1, arr2[1][-1] + 1)


n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ab.append(i)
		else:
			ba.append(i)
if (len(ab) + len(ba)) % 2 > 0:
	print(-1)
	return
swaps = []
while len(ab) > 1:
	swaps.append((ab.pop(), ab.pop()))
while len(ba) > 1:
	swaps.append((ba.pop(), ba.pop()))
if len(ab) > 0:
	t1 = ab.pop()
	t2 = ba.pop()
	swaps.append((t1, t1))
	swaps.append((t1, t2))
print(len(swaps))
for (t1, t2) in swaps:
	print(t1 + 1, t2 + 1)


n = int(input())
s = input()
t = input()
ba = ab = 0
vab = []
vba = []
ans1 = []
ans2 = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab += 1
		vab.append(i)
	elif s[i] == 'b' and t[i] == 'a':
		ba += 1
		vba.append(i)
lenab = len(vab)
lenba = len(vba)
iba = iab = -1
while lenab - 1 - iab > 1:
	iab += 1
	ans1.append(vab[iab])
	iab += 1
	ans2.append(vab[iab])
while lenba - 1 - iba > 1:
	iba += 1
	ans1.append(vba[iba])
	iba += 1
	ans2.append(vba[iba])
if lenab - 1 - iab == 1 and lenba - 1 - iba == 1:
	iab += 1
	iba += 1
	ans1.append(vba[iba])
	ans2.append(vba[iba])
	ans1.append(vba[iba])
	ans2.append(vab[iab])
elif lenab - 1 - iab == 0 and lenba - 1 - iba == 0:
	pass
else:
	print('-1')
	exit(0)
print(len(ans1))
for i in range(len(ans1)):
	print(ans1[i] + 1, ans2[i] + 1)


n = int(input())
s = input()
t = input()
ab = []
ba = []
ans = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
while len(ba) >= 2:
	l1 = []
	l1.append(ba.pop())
	l1.append(ba.pop())
	ans.append(l1)
while len(ab) >= 2:
	l1 = []
	l1.append(ab.pop())
	l1.append(ab.pop())
	ans.append(l1)
if len(ab) == 1 and len(ba) == 1:
	print(len(ans) + 2)
	for i in ans:
		print(i[0], i[1])
	print(ab[0], ab[0])
	print(ab[0], ba[0])
if len(ab) == 1 and len(ba) == 0 or (len(ab) == 0 and len(ba) == 1):
	print(-1)
if len(ab) == 0 and len(ba) == 0:
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


n = int(input())
(s, t) = (input(), input())
(ai, bi) = ([], [])
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ai.append(i + 1)
		else:
			bi.append(i + 1)
if (len(ai) + len(bi)) % 2 > 0:
	print(-1)
	exit(0)
print(len(ai) // 2 + len(bi) // 2 + 2 * (len(bi) % 2))
while len(ai) >= 2:
	print(ai.pop(), ai.pop())
while len(bi) >= 2:
	print(bi.pop(), bi.pop())
if len(ai) > 0:
	assert len(bi) > 0
	print(ai[0], ai[0])
	print(ai[0], bi[0])


for _ in range(1):
	n = int(input())
	s = input()
	t = input()
	pos01 = []
	pos10 = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				pos01.append(i)
			else:
				pos10.append(i)
	if len(pos10) % 2 == len(pos01) % 2:
		ans = []
		for i in range(0, len(pos01), 2):
			if i + 1 < len(pos01):
				ans.append((pos01[i], pos01[i + 1]))
			else:
				break
		for i in range(0, len(pos10), 2):
			if i + 1 < len(pos10):
				ans.append((pos10[i], pos10[i + 1]))
			else:
				break
		if len(pos01) % 2:
			x = pos01[-1]
			y = pos10[-1]
			ans.append((x, x))
			ans.append((x, y))
		print(len(ans))
		for info in ans:
			print(info[0] + 1, info[1] + 1)
	else:
		print(-1)


n = int(input())
s = [sym for sym in input()]
t = [sym for sym in input()]
num_of_a_char = s.count('a') + t.count('a')
num_of_b_char = s.count('b') + t.count('b')
if num_of_a_char % 2 != 0 or num_of_b_char % 2 != 0:
	print(-1)
else:
	num_of_operations = 0
	indices = []
	symbol_a_from_s = 0
	symbol_a_from_t = 0
	for ind in range(n):
		if s[ind] != t[ind]:
			symbol_a_from_s += 1 if s[ind] == 'a' else 0
			symbol_a_from_t += 1 if t[ind] == 'a' else 0
	flag = 0
	pair = []
	ind = 0
	while symbol_a_from_s > 1 and ind < n:
		if s[ind] != t[ind] and s[ind] == 'a':
			if flag == 0:
				pair.append(ind + 1)
				flag = 1
			else:
				pair.append(ind + 1)
				(s[pair[0] - 1], t[pair[1] - 1]) = ('b', 'a')
				indices.append(pair)
				pair = []
				flag = 0
				num_of_operations += 1
				symbol_a_from_s -= 2
		ind += 1
	flag = 0
	pair = []
	ind = 0
	while symbol_a_from_t > 1 and ind < n:
		if s[ind] != t[ind] and t[ind] == 'a':
			if flag == 0:
				pair.append(ind + 1)
				flag = 1
			else:
				pair.append(ind + 1)
				(s[pair[0] - 1], t[pair[1] - 1]) = ('a', 'b')
				indices.append(pair)
				pair = []
				flag = 0
				num_of_operations += 1
				symbol_a_from_t -= 2
		ind += 1
	if symbol_a_from_s <= symbol_a_from_t:
		for ind in range(n):
			if s[ind] != t[ind] and s[ind] == 'a':
				indices.append([ind + 1, ind + 1])
				(s[ind], t[ind]) = (t[ind], s[ind])
				num_of_operations += 1
		flag = 0
		pair = []
		for ind in range(n):
			if s[ind] != t[ind]:
				if flag == 0:
					pair.append(ind + 1)
					flag = 1
				else:
					pair.append(ind + 1)
					indices.append(pair)
					pair = []
					flag = 0
					num_of_operations += 1
	else:
		for ind in range(n):
			if s[ind] != t[ind] and t[ind] == 'a':
				indices.append([ind + 1, ind + 1])
				(s[ind], t[ind]) = (t[ind], s[ind])
				num_of_operations += 1
		flag = 0
		pair = []
		for ind in range(n):
			if s[ind] != t[ind]:
				if flag == 0:
					pair.append(ind + 1)
					flag = 1
				else:
					pair.append(ind + 1)
					indices.append(pair)
					pair = []
					flag = 0
					num_of_operations += 1
	print(num_of_operations)
	for pair in indices:
		print(*pair)


n = int(input())
a = [int(c == 'b') for c in input()]
b = [int(c == 'b') for c in input()]
x = [i + 1 for i in range(n) if (a[i], b[i]) == (0, 1)]
y = [i + 1 for i in range(n) if (a[i], b[i]) == (1, 0)]
if len(x) & 1 ^ len(y) & 1 == 1:
	print(-1)
	return
cnt = 0
res = []
while len(x) > 1:
	res.append(f'{x.pop()} {x.pop()}')
	cnt += 1
while len(y) > 1:
	res.append(f'{y.pop()} {y.pop()}')
	cnt += 1
if len(x) == 1:
	(c, d) = (x[0], y[0])
	res.append(f'{c} {c}')
	res.append(f'{c} {d}')
	cnt += 2
print(cnt)
print('\n'.join(res))


n = int(input())
s1 = input()
s2 = input()

def get_result(s1, s2):
	result = []
	diffAB = set()
	diffBA = set()
	for i in range(0, n):
		if s1[i] != s2[i]:
			if s1[i] == 'b':
				diffBA.add(i)
			else:
				diffAB.add(i)
	count = len(diffAB) + len(diffBA)
	if count == 0:
		return 0
	if count % 2 != 0:
		return -1
	while len(diffBA) >= 2:
		a = diffBA.pop()
		b = diffBA.pop()
		result.append((a, b))
	while len(diffAB) >= 2:
		a = diffAB.pop()
		b = diffAB.pop()
		result.append((a, b))
	if len(diffAB) != 0:
		ab = diffAB.pop()
		ba = diffBA.pop()
		result.append((ab, ab))
		result.append((ab, ba))
	return result
r = get_result(s1, s2)
if not isinstance(r, list):
	print(r)
else:
	print(len(r))
	for (a, b) in r:
		print(a + 1, b + 1)


from math import *
n = int(input())
l1 = list(input())
l2 = list(input())
ca = 0
for i in range(n):
	if l1[i] == 'a':
		ca += 1
	if l2[i] == 'a':
		ca += 1
if ca % 2 != 0:
	print(-1)
else:
	ab = []
	ba = []
	for i in range(n):
		if l1[i] == 'a' and l2[i] == 'b':
			ab.append(i + 1)
		if l1[i] == 'b' and l2[i] == 'a':
			ba.append(i + 1)
	count = ceil(len(ab) / 2) + ceil(len(ba) / 2)
	print(count)
	c = d = -1
	for i in range(0, len(ab), 2):
		if i == len(ab) - 1:
			c = ab[i]
		else:
			print(ab[i], ab[i + 1])
	for i in range(0, len(ba), 2):
		if i == len(ba) - 1:
			d = ba[i]
		else:
			print(ba[i], ba[i + 1])
	if c != -1:
		print(c, c)
		print(c, d)


n = int(input())
s = input()
t = input()
ans = []
if (s.count('a') + t.count('a')) % 2 or (s.count('b') + t.count('b')) % 2:
	print(-1)
else:
	ba = []
	ab = []
	t1 = []
	t2 = []
	for i in range(n):
		if s[i] == 'a' and t[i] == 'b':
			t1.append(i + 1)
			if len(t1) == 2:
				ab.append(t1)
				t1 = []
		elif s[i] == 'b' and t[i] == 'a':
			t2.append(i + 1)
			if len(t2) == 2:
				ba.append(t2)
				t2 = []
	for i in ab:
		ans.append(i)
	for i in ba:
		ans.append(i)
	if t1 and t2:
		t1 = t1[-1]
		t2 = t2[-1]
		ans.append((t1, t1))
		ans.append((t2, t1))
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
s1 = input()
s2 = input()
if s1.count('a') + s2.count('a') & 1:
	print(-1)
	exit()
alpha = []
beta = []
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		alpha.append(i)
	elif s1[i] == 'b' and s2[i] == 'a':
		beta.append(i)
print(len(alpha) // 2 + len(beta) // 2 + 2 * (len(alpha) & 1))
for j in range(len(alpha) // 2):
	print(1 + alpha[2 * j], 1 + alpha[2 * j + 1])
for j in range(len(beta) // 2):
	print(1 + beta[2 * j], 1 + beta[2 * j + 1])
if len(alpha) & 1:
	h = alpha[-1]
	k = beta[-1]
	print(h + 1, h + 1)
	print(h + 1, k + 1)


from sys import stdin, stdout
from math import gcd, sqrt, inf
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = inf
n = I()
a = S()
b = S()
x = []
y = []
d = {'a': 0, 'b': 0}
for i in range(n):
	if 'a' == a[i] != b[i]:
		x += (i + 1,)
	elif 'b' == a[i] != b[i]:
		y += (i + 1,)
	d[a[i]] += 1
	d[b[i]] += 1
if not d['a'] % 2 == d['b'] % 2 == 0:
	exit(print(-1))
op = 0
ans = []
ln_x = len(x)
ln_y = len(y)
for i in range(0, ln_x - ln_x % 2, 2):
	ans += ((x[i], x[i + 1]),)
	op += 1
for i in range(0, ln_y - ln_y % 2, 2):
	ans += ((y[i], y[i + 1]),)
	op += 1
if ln_x & 1:
	ans += ((x[-1], x[-1]),)
	ans += ((x[-1], y[-1]),)
	op += 2
print(op)
for i in ans:
	print(*i)


def main():
	input()
	first = input()
	second = input()
	fa = []
	fb = []
	for (i, (ci, cj)) in enumerate(zip(first, second), 1):
		if ci == 'a' and cj == 'b':
			fa.append(i)
		elif ci == 'b' and cj == 'a':
			fb.append(i)
	if len(fa) % 2 != len(fb) % 2:
		print(-1)
		return
	couples = []
	if len(fa) % 2 == len(fb) % 2 == 1:
		p = fa.pop()
		fb.append(p)
		couples.append((p, p))
	for i in range(0, len(fa), 2):
		couples.append((fa[i], fa[i + 1]))
	for i in range(0, len(fb), 2):
		couples.append((fb[i], fb[i + 1]))
	print(len(couples))
	for c in couples:
		print(*c)
main()


n = int(input())
s = input()
t = input()
ab = []
ba = []
for (idx, pair) in enumerate(zip(s, t)):
	if pair == ('a', 'b'):
		ab.append(idx + 1)
	if pair == ('b', 'a'):
		ba.append(idx + 1)
ans = []
for i in range(1, len(ab), 2):
	ans += [[ab[i - 1], ab[i]]]
for i in range(1, len(ba), 2):
	ans += [[ba[i - 1], ba[i]]]
if len(ab) % 2 != len(ba) % 2:
	print(-1)
	exit(0)
if len(ab) % 2:
	ans.append([ab[-1], ab[-1]])
	ans.append([ba[-1], ab[-1]])
print(len(ans))
for (x, y) in ans:
	print(x, y)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
if (len(ab) + len(ba)) % 2:
	print(-1)
	exit()
cnt = 0
ans = []
while len(ab) >= 2:
	tmp1 = ab.pop()
	tmp2 = ab.pop()
	ans.append([tmp1, tmp2])
	cnt += 1
while len(ba) >= 2:
	tmp1 = ba.pop()
	tmp2 = ba.pop()
	ans.append([tmp1, tmp2])
	cnt += 1
if len(ab) == 1:
	tmp1 = ab.pop()
	tmp2 = ba.pop()
	ans.append([tmp1, tmp1])
	ans.append([tmp1, tmp2])
	cnt += 2
print(cnt)
for pair in ans:
	print(*pair)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = list(input().strip())
	b = list(input().strip())
	d = defaultdict(list)
	for i in range(n):
		if a[i] != b[i]:
			d[a[i], b[i]].append(i)
	ans = []
	c = 0
	for i in d:
		while len(d[i]) > 1:
			ans.append([d[i][-1] + 1, d[i][-2] + 1])
			del d[i][-1]
			del d[i][-1]
		if len(d[i]):
			c += 1
	if c == 1:
		print(-1)
		return
	p = []
	if c == 2:
		for i in d:
			p.append(d[i][-1])
		(p, q) = p
		ans.append([p + 1, p + 1])
		ans.append([p + 1, q + 1])
	print(len(ans))
	for i in ans:
		print(*i)
for _ in range(1):
	case()


def solve(n, a, b):
	s = []
	c = 0
	ans = []
	for i in range(n):
		if a[i] != b[i]:
			s.append([a[i], b[i], i + 1])
			c += 1
	if c % 2 != 0:
		return -1
	s.sort()
	i = 1
	while i < c:
		if s[i][0] == s[i - 1][0]:
			ans.append([s[i][2], s[i - 1][2]])
		else:
			ans.append([s[i][2], s[i][2]])
			ans.append([s[i - 1][2], s[i][2]])
		i += 2
	return ans
n = int(input())
a = list(input())
b = list(input())
p = solve(n, a, b)
if p == -1:
	print(-1)
else:
	print(len(p))
	for it in p:
		print(*it)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	s = input()
	t = input()
	AB = []
	BA = []
	for i in range(n):
		if s[i] == t[i]:
			continue
		elif s[i] == 'a':
			AB.append(i + 1)
		else:
			BA.append(i + 1)
	if (len(AB) + len(BA)) % 2 == 1:
		print(-1)
		return
	elif len(AB) % 2 == 0:
		print(len(AB) // 2 + len(BA) // 2)
		for i in range(0, len(AB), 2):
			print(AB[i], AB[i + 1])
		for i in range(0, len(BA), 2):
			print(BA[i], BA[i + 1])
		return
	else:
		print(len(AB) // 2 + len(BA) // 2 + 2)
		for i in range(0, len(AB) - 1, 2):
			print(AB[i], AB[i + 1])
		for i in range(0, len(BA) - 1, 2):
			print(BA[i], BA[i + 1])
		print(AB[-1], AB[-1])
		print(AB[-1], BA[-1])
mode = 'r'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


n = int(input())
a = list(input())
b = list(input())
(indab, indba) = ([], [])
(ab, ba) = (0, 0)
for i in range(n):
	if a[i] != b[i]:
		if a[i] == 'a':
			ab += 1
			indab.append(i + 1)
		else:
			ba += 1
			indba.append(i + 1)
op = ab // 2 + ba // 2
ab %= 2
ba %= 2
if ab != ba:
	print(-1)
else:
	if ab == 1:
		op += 2
	print(op)
	for i in range(1, len(indab), 2):
		print(indab[i - 1], indab[i])
	for i in range(1, len(indba), 2):
		print(indba[i - 1], indba[i])
	if ab == 1:
		print(indab[-1], indab[-1])
		print(indab[-1], indba[-1])


n = int(input())
s = list(input())
t = list(input())
s1 = []
l1 = 0
s2 = []
l2 = 0
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			s1.append(i + 1)
			l1 += 1
		else:
			s2.append(i + 1)
			l2 += 1
if l1 % 2 == l2 % 2:
	ans = []
	ansL = 0
	for i in range(0, l1 - 1, 2):
		ans.append([s1[i], s1[i + 1]])
		ansL += 1
	for i in range(0, l2 - 1, 2):
		ans.append([s2[i], s2[i + 1]])
		ansL += 1
	if l1 % 2 != 0:
		ansL += 2
		ans.append([s1[l1 - 1], s1[l1 - 1]])
		ans.append([s1[l1 - 1], s2[l2 - 1]])
	print(ansL)
	for i in ans:
		print(i[0], i[1])
else:
	print(-1)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	S = listStr()
	T = listStr()
	diff10 = [j + 1 for j in range(N) if S[j] == 'a' and T[j] == 'b']
	diff01 = [j + 1 for j in range(N) if S[j] == 'b' and T[j] == 'a']
	if (len(diff10) + len(diff01)) % 2 == 1:
		print(-1)
		return
	ans = []
	while len(diff10) > 1:
		(j1, j2) = (diff10.pop(), diff10.pop())
		ans.append((j1, j2))
	while len(diff01) > 1:
		(j1, j2) = (diff01.pop(), diff01.pop())
		ans.append((j1, j2))
	if diff10:
		j1 = diff10.pop()
		j2 = diff01.pop()
		ans.append((j1, j1))
		ans.append((j1, j2))
	print(len(ans))
	for (j1, j2) in ans:
		print(j1, j2)
	return
solve()


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a / gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 0
	right = len(a)
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
n = I()
s = input()
t = input()
a = []
b = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			a.append(i + 1)
		else:
			b.append(i + 1)
if len(a + b) % 2 != 0:
	print(-1)
else:
	if len(a) % 2 == 0:
		print(len(a) // 2 + len(b) // 2)
	else:
		print(len(a) // 2 + len(b) // 2 + 2)
	for i in range(1, len(a), 2):
		print(a[i - 1], a[i])
	for i in range(1, len(b), 2):
		print(b[i - 1], b[i])
	if len(a) % 2 != 0:
		print(a[-1], a[-1])
		print(b[-1], a[-1])


import sys

def main():
	n = int(sys.stdin.readline().strip())
	for _ in range(1):
		s = sys.stdin.readline().strip()
		t = sys.stdin.readline().strip()
		aa = []
		ab = []
		ba = []
		bb = []
		i = 0
		for (k, l) in zip(s, t):
			if k == 'a' and l == 'a':
				aa.append(i)
			elif k == 'a' and l == 'b':
				ab.append(i)
			elif k == 'b' and l == 'a':
				ba.append(i)
			elif k == 'b' and l == 'b':
				bb.append(i)
			else:
				assert False
			i += 1
		res = ''
		n = 0
		while len(ab) > 1:
			res += '%d %d\n' % (ab.pop() + 1, ab.pop() + 1)
			n += 1
		while len(ba) > 1:
			n += 1
			res += '%d %d\n' % (ba.pop() + 1, ba.pop() + 1)
		if len(ab) != len(ba):
			print(-1)
			break
		if len(ab) > 0:
			n += 2
			res += '%d %d\n' % (ab[0] + 1, ab[0] + 1)
			res += '%d %d\n' % (ab[0] + 1, ba[0] + 1)
		print(n)
		if n:
			print(res, end='')
main()


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
n = getInt()
s1 = getStr()
s2 = getStr()
d1 = []
d2 = []
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			d1.append(i + 1)
		else:
			d2.append(i + 1)
if (len(d1) + len(d2)) % 2 > 0:
	print(-1)
else:
	if len(d1) < len(d2):
		(d1, d2) = (d2, d1)
	res = len(d1) // 2 + len(d2) // 2 + len(d1) % 2 + len(d2) % 2
	print(res)
	for i in range(1, len(d1), 2):
		print(d1[i - 1], d1[i])
	for i in range(1, len(d2), 2):
		print(d2[i - 1], d2[i])
	if len(d1) % 2 == 1:
		print(d2[-1], d2[-1])
		print(d2[-1], d1[-1])


n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ab.append(i)
		else:
			ba.append(i)
if (len(ab) + len(ba)) % 2 == 1:
	print(-1)
else:
	seq = []
	ai = 0
	while ai + 1 < len(ab):
		seq.append([ab[ai], ab[ai + 1]])
		ai += 2
	bi = 0
	while bi + 1 < len(ba):
		seq.append([ba[bi], ba[bi + 1]])
		bi += 2
	if ai == len(ab) - 1:
		seq.append([ab[ai], ab[ai]])
		seq.append([ba[bi], ab[ai]])
	print(len(seq))

	def multiLineArrayOfArraysPrint(arr):
		print('\n'.join([' '.join([str(x + 1) for x in y]) for y in arr]))
	multiLineArrayOfArraysPrint(seq)


N = int(input())
s1 = list(input())
s2 = list(input())
total = 0
swaps = []
isPossible = True
lastGood = 0
while True:
	for i in range(lastGood, N):
		if s1[i] != s2[i]:
			break
	else:
		break
	foundNice = False
	for j in range(i + 1, N):
		if s1[i] == s1[j] and s2[i] == s2[j]:
			foundNice = True
			break
	if foundNice:
		swaps.append((i + 1, j + 1))
		(s1[i], s2[j]) = (s2[j], s1[i])
	else:
		for j in range(i + 1, N):
			if s1[j] != s2[j]:
				break
		else:
			print(-1)
			isPossible = False
			break
		swaps.append((i + 1, i + 1))
		swaps.append((i + 1, j + 1))
		(s2[i], s2[j]) = (s2[j], s2[i])
	total += 1
	lastGood = i
if isPossible:
	print(len(swaps))
	for (p1, p2) in swaps:
		print(p1, p2)


n = int(input())
s1 = input()
s2 = input()
if s1 == s2:
	print(0)
else:
	arr_ab = []
	arr_ba = []
	for i in range(n):
		if s1[i] != s2[i] and s1[i] + s2[i] == 'ab':
			arr_ab.append(i + 1)
		elif s1[i] != s2[i] and s1[i] + s2[i] == 'ba':
			arr_ba.append(i + 1)
	if len(arr_ab) % 2 == 1 and len(arr_ba) % 2 == 0:
		print(-1)
	elif len(arr_ab) % 2 == 0 and len(arr_ba) % 2 == 1:
		print(-1)
	else:
		ans = []
		while len(arr_ab) > 1:
			ans.append([arr_ab.pop(), arr_ab.pop()])
		while len(arr_ba) > 1:
			ans.append([arr_ba.pop(), arr_ba.pop()])
		if len(arr_ab) > 0 and len(arr_ba) > 0:
			(k1, k2) = (arr_ab.pop(), arr_ba.pop())
			ans.append([max(k1, k2), max(k1, k2)])
			ans.append([max(k1, k2), min(k1, k2)])
		print(len(ans))
		for i in ans:
			print(*i)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
s = ri()
t = ri()
cnt = [0] * 26
for i in s:
	cnt[ord(i) - ord('a')] += 1
for i in t:
	cnt[ord(i) - ord('a')] += 1
flag = True
for i in cnt:
	if i % 2 != 0:
		flag = False
		break
if not flag:
	print(-1)
	exit()
(cnt1, cnt2) = ([], [])
for i in range(n):
	if s[i] == 'a' and s[i] != t[i]:
		cnt1.append(i)
	if s[i] == 'b' and s[i] != t[i]:
		cnt2.append(i)
totans = []
for i in range(0, len(cnt1) - 1, 2):
	totans.append((cnt1[i] + 1, cnt1[i + 1] + 1))
for i in range(0, len(cnt2) - 1, 2):
	totans.append((cnt2[i] + 1, cnt2[i + 1] + 1))
if len(cnt1) % 2 != 0 or len(cnt1) % 2 != 0:
	totans.append((cnt1[-1] + 1, cnt1[-1] + 1))
	totans.append((cnt1[-1] + 1, cnt2[-1] + 1))
print(len(totans))
for i in totans:
	print(*i)


n = int(input())
a = input()
b = input()
d = {'ab': 0, 'ba': 0}
ca = 0
cb = 0
for i in range(n):
	if a[i] == 'a':
		ca += 1
	else:
		cb += 1
	if b[i] == 'a':
		ca += 1
	else:
		cb += 1
if ca % 2 == 1 or cb % 2 == 1:
	print(-1)
else:
	for i in range(n):
		if a[i] != b[i]:
			d[a[i] + b[i]] += 1
	print(d['ab'] // 2 + d['ba'] // 2 + d['ab'] % 2 + d['ba'] % 2)
	cross = False
	if d['ab'] != 0:
		prev = False
		for i in range(n):
			if a[i] + b[i] == 'ab':
				if not prev:
					prev = True
					pi = i
				else:
					print(pi + 1, i + 1)
					prev = False
		if prev:
			cross = pi + 1
	if d['ba'] != 0:
		prev = False
		for i in range(n):
			if a[i] + b[i] == 'ba':
				if not prev:
					prev = True
					pi = i
				else:
					print(pi + 1, i + 1)
					prev = False
		if cross:
			print(cross, cross)
			print(cross, pi + 1)


a = int(input())
s = input()
r = input()
cmap = []
tmap = []
for i in range(len(s)):
	if s[i] == 'a' and r[i] == 'b':
		cmap.append(i)
	elif s[i] == 'b' and r[i] == 'a':
		tmap.append(i)
r = len(cmap)
t = len(tmap)
if r % 2 == 1 and t % 2 == 0 or (r % 2 == 0 and t % 2 == 1):
	print(-1)
else:
	total = r // 2 + t // 2
	if r % 2 == 1 and t % 2 == 1:
		print(total + 2)
		for i in range(0, len(cmap) - 1, 2):
			print(cmap[i] + 1, cmap[i + 1] + 1)
		for i in range(0, len(tmap) - 1, 2):
			print(tmap[i] + 1, tmap[i + 1] + 1)
		print(cmap[-1] + 1, cmap[-1] + 1)
		print(cmap[-1] + 1, tmap[-1] + 1)
	else:
		print(total)
		for i in range(0, len(cmap), 2):
			print(cmap[i] + 1, cmap[i + 1] + 1)
		for i in range(0, len(tmap), 2):
			print(tmap[i] + 1, tmap[i + 1] + 1)


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	nonlocal factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	nonlocal fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	n = get_int()
	s = list(stdin.readline().strip())
	t = list(stdin.readline().strip())
	(type1, type2) = ([], [])
	res = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] > t[i]:
				type1.append(i)
			else:
				type2.append(i)
	if len(type1) % 2 != len(type2) % 2:
		print(-1)
	else:
		k = len(type1) // 2
		for i in range(k):
			res.append([type1[2 * i] + 1, type1[2 * i + 1] + 1])
		k = len(type2) // 2
		for i in range(k):
			res.append([type2[2 * i] + 1, type2[2 * i + 1] + 1])
		if len(type1) % 2 != 0:
			i = type1[-1]
			j = type2[-1]
			res.append([i + 1, i + 1])
			res.append([i + 1, j + 1])
		print(len(res))
		for li in res:
			display_list(li)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


import sys
n = int(input())
s = input()
t = input()
l1 = []
l2 = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		l1.append(i + 1)
	if s[i] == 'b' and t[i] == 'a':
		l2.append(i + 1)
if (len(l1) + len(l2)) % 2 != 0:
	print(-1)
	sys.exit()
if len(l1) % 2 != 0:
	ans = int(len(l1) / 2) + int(len(l2) / 2) + 2
	print(ans)
	for i in range(1, len(l1) - 1, 2):
		print(l1[i - 1], l1[i])
	for i in range(2, len(l2), 2):
		print(l2[i - 1], l2[i])
	print(l1[len(l1) - 1], l1[len(l1) - 1])
	print(l1[len(l1) - 1], l2[0])
else:
	ans = int(len(l1) / 2) + int(len(l2) / 2)
	print(ans)
	for i in range(1, len(l1), 2):
		print(l1[i - 1], l1[i])
	for i in range(1, len(l2), 2):
		print(l2[i - 1], l2[i])


n = int(input())
s1 = input()
s2 = input()
liab = [0] * n
liba = [0] * n
coab = 0
coba = 0
ha = 0
hb = 0
for i in range(n):
	if s1[i] == 'a':
		ha += 1
	if s2[i] == 'a':
		ha += 1
	if s1[i] == 'b':
		hb += 1
	if s2[i] == 'b':
		hb += 1
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		liab[i] = 1
		coab += 1
	elif s1[i] == 'b' and s2[i] == 'a':
		liba[i] = 1
		coba += 1
if ha % 2 != 0 and hb % 2 != 0:
	print(-1)
else:
	if coab % 2 != 0:
		coab = coab // 2 + 1
	else:
		coab = coab // 2
	if coba % 2 != 0:
		coba = coba // 2 + 1
	else:
		coba = coba // 2
	print(coab + coba)
	cf = 1
	ls = -1
	for i in range(n):
		if liab[i] == 1 and cf == 0:
			print(i + 1)
			cf = 1
		elif liab[i] == 1 and cf == 1:
			print(i + 1, end=' ')
			cf = 0
			ls = i + 1
	if cf == 0 and ls != -1:
		print(ls)
		print(ls, end=' ')
	for i in range(n):
		if liba[i] == 1 and cf == 1:
			print(i + 1, end=' ')
			cf = 0
		elif liba[i] == 1 and cf == 0:
			print(i + 1)
			cf = 1


n = int(input())
s = input()
t = input()
cnt_s_a = 0
cnt_t_a = 0
for i in range(n):
	if s[i] == 'a':
		cnt_s_a += 1
	if t[i] == 'a':
		cnt_t_a += 1
if (cnt_t_a + cnt_s_a) % 2 == 1:
	print(-1)
	return
b_a = []
a_b = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		a_b.append(i)
	if s[i] == 'b' and t[i] == 'a':
		b_a.append(i)
ans = []
for i in range(len(a_b) // 2):
	ans.append((a_b[2 * i] + 1, a_b[2 * i + 1] + 1))
for i in range(len(b_a) // 2):
	ans.append((b_a[2 * i] + 1, b_a[2 * i + 1] + 1))
if len(a_b) % 2 == 1:
	ans.append((a_b[-1] + 1, a_b[-1] + 1))
	ans.append((a_b[-1] + 1, b_a[-1] + 1))
print(len(ans))
for i in ans:
	print(*i)


import math
import random
import sys
n = int(input())
s = str(input())
t = str(input())
ab = []
ba = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ab.append(i + 1)
		else:
			ba.append(i + 1)
if len(ab) % 2 != len(ba) % 2:
	print(-1)
else:
	print((len(ab) + len(ba)) // 2 + int(len(ab) % 2 != 0))
	it = 0
	while len(ab) - 1 > it:
		print(ab[it], ab[it + 1])
		it += 2
	it = 0
	while len(ba) - 1 > it:
		print(ba[it], ba[it + 1])
		it += 2
	if len(ab) % 2 != 0:
		print(ab[-1], ab[-1])
		print(ab[-1], ba[-1])


n = int(input())
p = input().rstrip()
s2 = input().rstrip()
x = list(p)
y = list(s2)
L = []
Q = []
W = []
S = []
D = []
if len(x) != len(y):
	print(-1)
else:
	D = [0] * 257
	G = 0
	for i in range(0, len(x)):
		if x[i] != y[i]:
			if x[i] == 'b':
				L.append(i)
			else:
				Q.append(i)
	if len(L) % 2 != 0 and len(Q) % 2 == 0:
		print(-1)
	elif len(L) % 2 == 0 and len(Q) % 2 != 0:
		print(-1)
	elif len(L) % 2 == 0 and len(Q) % 2 == 0:
		print(len(L) // 2 + len(Q) // 2)
		for i in range(0, len(L), 2):
			print(L[i] + 1, L[i + 1] + 1)
		L = Q
		for i in range(0, len(L), 2):
			print(L[i] + 1, L[i + 1] + 1)
	else:
		A = L[len(L) - 1]
		B = Q[len(Q) - 1]
		del L[len(L) - 1]
		del Q[len(Q) - 1]
		ans = len(L) // 2
		ans += len(Q) // 2
		ans += 2
		print(ans)
		for i in range(0, len(L), 2):
			print(L[i] + 1, L[i + 1] + 1)
		L = Q
		for i in range(0, len(L), 2):
			print(L[i] + 1, L[i + 1] + 1)
		print(A + 1, A + 1)
		print(A + 1, B + 1)


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = IN(1)
a = input()
b = input()
ab = []
ba = []
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		ab.append(i + 1)
	elif a[i] == 'b' and b[i] == 'a':
		ba.append(i + 1)
h = []
y1 = len(ab) % 2
for i in range(1, len(ab), 2):
	h.append([ab[i - 1], ab[i]])
y2 = len(ba) % 2
for i in range(1, len(ba), 2):
	h.append([ba[i - 1], ba[i]])
if y1 != y2:
	print(-1)
elif y1 == 0:
	print(len(h))
	for i in h:
		print(i[0], i[1])
else:
	print(len(h) + 2)
	for i in h:
		print(i[0], i[1])
	print(ab[-1], ab[-1])
	print(ab[-1], ba[-1])


N = int(input())
S = list(input())
T = list(input())
ab = []
ba = []
for i in range(N):
	if S[i] == 'a' and T[i] == 'b':
		ab.append(i)
	elif S[i] == 'b' and T[i] == 'a':
		ba.append(i)
if (len(ab) + len(ba)) % 2 == 1:
	print(-1)
else:
	c = (len(ab) + len(ba)) // 2
	change = -1
	if len(ab) % 2 == 1:
		k = ab.pop()
		ba.append(k)
		change = k
		c += 1
	print(c)
	if change != -1:
		print(change + 1, change + 1)
	for i in range(len(ab) // 2):
		print(ab[2 * i] + 1, ab[2 * i + 1] + 1)
	for i in range(len(ba) // 2):
		print(ba[2 * i] + 1, ba[2 * i + 1] + 1)


n = int(input())
a = input()
s = input()
(d1, d2) = ([], [])
for q in range(n):
	if a[q] == 'a' and s[q] == 'b':
		d1.append(q + 1)
	elif a[q] == 'b' and s[q] == 'a':
		d2.append(q + 1)
if (len(d1) + len(d2)) % 2 == 1:
	print(-1)
else:
	print((len(d1) + len(d2)) // 2 + len(d1) % 2)
	for q in range(1, len(d1), 2):
		print(d1[q - 1], d1[q])
	for q in range(1, len(d2), 2):
		print(d2[q - 1], d2[q])
	if len(d1) % 2 == 1:
		print(d1[-1], d1[-1])
		print(d1[-1], d2[-1])


n = int(input())
s = input()
t = input()
(a, b) = (0, 0)
f = {('a', 'b'): [], ('b', 'a'): []}
u = []
for i in range(n):
	if t[i] == 'a':
		a += 1
	if s[i] == 'a':
		a += 1
	if t[i] == 'b':
		b += 1
	if s[i] == 'b':
		b += 1
	if t[i] != s[i]:
		if (t[i], s[i]) in f and len(f[t[i], s[i]]) > 0:
			l = f[t[i], s[i]].pop()
			u.append([l + 1, i + 1])
		else:
			f[t[i], s[i]] = [i]
h = 0
if len(f['a', 'b']) == 0 and len(f['b', 'a']) == 1:
	print(-1)
	h += 1
elif len(f['b', 'a']) == 0 and len(f['a', 'b']) == 1:
	print(-1)
	h += 1
elif len(f['b', 'a']) == 1 and len(f['a', 'b']) == 1:
	u.append([f['a', 'b'][0] + 1, f['a', 'b'][0] + 1])
	u.append([f['a', 'b'][0] + 1, f['b', 'a'][0] + 1])
if h == 0:
	print(len(u))
	for j in u:
		print(*j)


num = int(input())
frow = input()
srow = input()
a = []
b = []
for i in range(num):
	if frow[i] != srow[i]:
		if srow[i] == 'a':
			b.append([1, i])
			a.append([2, i])
		else:
			a.append([1, i])
			b.append([2, i])
a = sorted(a, key=lambda x: x[0], reverse=True)
b = sorted(b, key=lambda x: x[0], reverse=False)
ch = []
if len(a) % 2 == 0:
	for i in range(0, len(a), 2):
		if a[i][0] == a[i + 1][0]:
			ch.append([a[i][1] + 1, a[i + 1][1] + 1])
		else:
			ch.append([a[i][1] + 1, a[i][1] + 1])
			ch.append([a[i][1] + 1, a[i + 1][1] + 1])
	print(len(ch))
	for i in ch:
		print(i[0], i[1])
else:
	print('-1')


n = int(input())
(s, t) = (input(), input())
(a, b) = (list(), list())
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		a.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		b.append(i + 1)
if (len(a) + len(b)) % 2 == 1:
	print(-1)
else:
	print((len(a) + len(b)) // 2 + len(a) % 2)
	for i in range(1, len(a), 2):
		print(a[i - 1], a[i])
	for i in range(1, len(b), 2):
		print(b[i - 1], b[i])
	if len(a) % 2 == 1:
		print(a[-1], a[-1])
		print(a[-1], b[-1])


n = int(input())
s = list(input())
t = list(input())
plat1 = []
plat2 = []
tot = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		plat1.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		plat2.append(i + 1)
m = len(plat1)
k = len(plat2)
for i in range(1, m, 2):
	tot.append((plat1[i - 1], plat1[i]))
for i in range(1, k, 2):
	tot.append((plat2[i - 1], plat2[i]))
if m % 2 == 1 and k % 2 == 1:
	(x, y) = (plat1[-1], plat2[-1])
	tot.append((x, x))
	tot.append((x, y))
elif m % 2 == 1 and k % 2 == 0 or (m % 2 == 0 and k % 2 == 1):
	print(-1)
	exit()
print(len(tot))
for item in tot:
	print(*item)


import sys
import math
from collections import Counter
from operator import itemgetter
import queue

def IO():
	sys.stdin = open('pyinput.txt', 'r')
	sys.stdout = open('pyoutput.txt', 'w')

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)

def LCM(a, b):
	return a * (b // GCD(a, b))

def scan(TYPE_1, TYPE_2=0):
	if TYPE_1 == int:
		return map(int, sys.stdin.readline().strip().split())
	elif TYPE_1 == float:
		return map(float, sys.stdin.readline().strip().split())
	elif TYPE_1 == list and TYPE_2 == float:
		return list(map(float, sys.stdin.readline().strip().split()))
	elif TYPE_1 == list and TYPE_2 == int:
		return list(map(int, sys.stdin.readline().strip().split()))
	elif TYPE_1 == str:
		return sys.stdin.readline().strip()
	else:
		print('ERROR!!!!')

def main():
	n = int(input())
	s1 = input()
	s2 = input()
	a = []
	b = []
	for i in range(n):
		if s1[i] != s2[i]:
			if s1[i] == 'a':
				a.append(i + 1)
			else:
				b.append(i + 1)
	if (len(a) + len(b)) % 2 != 0:
		print(-1)
		return
	ans = (len(a) + len(b)) // 2
	if len(a) % 2 != 0:
		ans += 1
	print(ans)
	if len(a) % 2 != 0:
		b.append(a[0])
		print(a[0], a[0])
		a = a[1:]
	for i in range(0, len(a), 2):
		print(a[i], a[i + 1])
	for i in range(0, len(b), 2):
		print(b[i], b[i + 1])
main()


x = int(input())
a = list(input())
b = list(input())
p = []
q = []
for n in range(x):
	if a[n] == 'a' and b[n] == 'b':
		p.append(n + 1)
	elif a[n] == 'b' and b[n] == 'a':
		q.append(n + 1)
if len(p) % 2 != len(q) % 2:
	print(-1)
	exit(0)
print(len(p) // 2 + len(q) // 2 + len(p) % 2 * 2)
for n in range(0, len(p), 2):
	if n < len(p) - 1:
		print(p[n], p[n + 1])
for n in range(0, len(q), 2):
	if n < len(q) - 1:
		print(q[n], q[n + 1])
if len(p) % 2:
	print(p[-1], p[-1])
	print(p[-1], q[-1])


n = int(input())
s = input()
t = input()
lastBA = lastAB = None
i = 0
ans = 0
steps = []

def addStep(x, y):
	global ans, steps
	ans += 1
	steps.append((x, y))
for (l, r) in zip(s, t):
	if (l, r) == ('a', 'b'):
		if lastAB is not None:
			addStep(lastAB, i)
			lastAB = None
		else:
			lastAB = i
	elif (l, r) == ('b', 'a'):
		if lastBA is not None:
			addStep(lastBA, i)
			lastBA = None
		else:
			lastBA = i
	i += 1
if (lastAB is not None) != (lastBA is not None):
	print(-1)
	quit()
if lastAB is not None:
	addStep(lastAB, lastAB)
	addStep(lastAB, lastBA)
print(ans)
for (x, y) in steps:
	print(x + 1, y + 1)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
n = int(input())
a = input()
b = input()
if (a.count('a') + b.count('a')) % 2 != 0:
	print(-1)
	sys.exit(0)
a = list(a)
b = list(b)
r = []
one = []
two = []
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		one.append(i + 1)
	elif a[i] == 'b' and b[i] == 'a':
		two.append(i + 1)
for i in range(0, len(one) - 1, 2):
	r.append((one[i], one[i + 1]))
for i in range(0, len(two) - 1, 2):
	r.append((two[i], two[i + 1]))
if len(one) % 2 == 1:
	r.append((one[-1], one[-1]))
	r.append((one[-1], two[-1]))
print(len(r))
for i in r:
	print(*i)


n = int(input())
s = list(input())
t = list(input())
ab = [idx for (idx, (s, t)) in enumerate(zip(s, t)) if (s == 'a') & (t == 'b')]
ba = [idx for (idx, (s, t)) in enumerate(zip(s, t)) if (s == 'b') & (t == 'a')]
if len(ab) + len(ba) & 1:
	print(-1)
else:
	print(len(ab) // 2 + len(ba) // 2 + len(ab) % 2 + len(ba) % 2)
	for (i, j) in zip(ab[::2], ab[1::2]):
		print(i + 1, j + 1)
	for (i, j) in zip(ba[::2], ba[1::2]):
		print(i + 1, j + 1)
	if len(ab) % 2 + len(ba) % 2:
		print(ab[-1] + 1, ab[-1] + 1)
		print(ab[-1] + 1, ba[-1] + 1)


def out(l):
	i = 0
	while i + 1 < len(l):
		print(l[i], l[i + 1])
		i += 2
n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	if s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
if len(ab) % 2 == len(ba) % 2:
	cnt = len(ab) // 2 + len(ba) // 2
	if len(ab) % 2 == 1:
		cnt += 2
	print(cnt)
	out(ab)
	out(ba)
	if len(ab) % 2 == 1:
		a = ab[len(ab) - 1]
		b = ba[len(ba) - 1]
		print(a, a)
		print(a, b)
else:
	print(-1)


n = int(input())
s1 = input()
s2 = input()
ab = []
ba = []

def one():
	global s1, s2
	global ab, ba
	for i in range(len(s1)):
		if s1[i] == 'a' and s2[i] == 'b':
			ab.append(i + 1)
		if s1[i] == 'b' and s2[i] == 'a':
			ba.append(i + 1)
if (s1.count('a') + s2.count('a')) % 2 == 1:
	print(-1)
elif s1 == s2:
	print(0)
else:
	one()
	(a, b) = (len(ab), len(ba))
	print(str(a // 2 + b // 2 + 2 * (a % 2)))
	i = 0
	while i + 1 < len(ab):
		print(str(ab[i]) + ' ' + str(ab[i + 1]))
		i += 2
	i = 0
	while i + 1 < len(ba):
		print(str(ba[i]) + ' ' + str(ba[i + 1]))
		i += 2
	if len(ab) % 2 == 1:
		(i, j) = (ab[len(ab) - 1], ba[len(ba) - 1])
		print(str(i) + ' ' + str(i))
		print(str(i) + ' ' + str(j))


N = int(input())
S = input()
T = input()
(ab, ba) = (-1, -1)
ans = []
for (p, (s, t)) in enumerate(zip(S, T)):
	i = p + 1
	if s + t == 'ab':
		if ab == -1:
			ab = i
		else:
			ans.append('%d %d' % (ab, i))
			ab = -1
	if s + t == 'ba':
		if ba == -1:
			ba = i
		else:
			ans.append('%d %d' % (ba, i))
			ba = -1
if ab == -1 and ba == -1:
	print(len(ans))
	print('\n'.join(ans))
elif ab != -1 and ba != -1:
	ans.append('%d %d' % (ab, ab))
	ans.append('%d %d' % (ab, ba))
	print(len(ans))
	print('\n'.join(ans))
else:
	print(-1)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
s = inp()
t = inp()
(a, b) = ([], [])
for i in range(n):
	if s[i] == t[i]:
		continue
	if s[i] == 'a':
		a.append(i + 1)
	else:
		b.append(i + 1)
if (len(a) + len(b)) % 2:
	print(-1)
else:
	ml = []
	for i in range(0, len(a) - 1, 2):
		ml.append((a[i], a[i + 1]))
	for i in range(0, len(b) - 1, 2):
		ml.append((b[i], b[i + 1]))
	if len(a) % 2:
		i = a[-1]
		j = b[-1]
		ml.append((i, i))
		ml.append((i, j))
	print(len(ml))
	for i in ml:
		print(*i)


from collections import Counter
n = int(input())
s = input()
t = input()
x1 = Counter(s)
x2 = Counter(t)
if (x1['a'] + x2['a']) % 2 != 0 or (x1['b'] + x2['b']) % 2 != 0:
	print(-1)
else:
	l1 = []
	l2 = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				l1.append(i + 1)
			else:
				l2.append(i + 1)
	ans = []
	for j in range(0, len(l1) - 1, 2):
		zz = [l1[j], l1[j + 1]]
		ans.append(zz)
	for jr in range(0, len(l2) - 1, 2):
		zz1 = [l2[jr], l2[jr + 1]]
		ans.append(zz1)
	if len(l1) % 2:
		w1 = l1[-1]
		w2 = l2[-1]
		a11 = [w1, w1]
		a12 = [w1, w2]
		ans.append(a11)
		ans.append(a12)
	print(len(ans))
	for ty in ans:
		print(*ty)


n = int(input())
s = input()
t = input()
type1s = []
type2s = []
for i in range(len(s)):
	c1 = s[i]
	c2 = t[i]
	if c1 == c2:
		continue
	if c1 == 'a':
		type1s.append(i + 1)
	else:
		type2s.append(i + 1)
type1 = len(type1s)
type2 = len(type2s)
ans = type1 // 2 + type2 // 2
mod1 = type1 % 2
mod2 = type2 % 2
if mod1 != mod2:
	ans = -1
elif mod1 == 1:
	ans += 2
print(ans)
if ans != -1:
	for i in range(0, type1 - 1, 2):
		print(type1s[i + 1], type1s[i])
	for i in range(0, type2 - 1, 2):
		print(type2s[i + 1], type2s[i])
	if mod1 == 1 and mod2 == 1:
		print(type1s[-1], type1s[-1])
		print(type1s[-1], type2s[-1])


n = int(input())
a = str(input())
b = str(input())
arr_a = [0] * n
arr_b = [0] * n
count_1 = 0
count_2 = 0
for i in range(n):
	if a[i] != b[i]:
		if a[i] == 'a':
			arr_a[i] = 1
			arr_b[i] = 2
			count_1 += 1
		else:
			arr_b[i] = 1
			arr_a[i] = 2
			count_2 += 1
pa = []
pb = []
if (count_1 + count_2) % 2 == 0:
	for i in range(n):
		if arr_a[i] == 1:
			pa.append(i + 1)
		elif arr_a[i] == 2:
			pb.append(i + 1)
	result = 0
	result += count_1 // 2 + count_2 // 2
	result += 2 * (count_1 % 2)
	print(result)
	l1 = len(pa)
	l2 = len(pb)
	if count_1 % 2 == 1:
		print(str(pa[l1 - 1]) + ' ' + str(pa[l1 - 1]))
		print(str(pb[l2 - 1]) + ' ' + str(pa[l1 - 1]))
		pa.pop()
		pb.pop()
	for i in range(len(pa) // 2):
		print(str(pa[2 * i]) + ' ' + str(pa[2 * i + 1]))
	for i in range(len(pb) // 2):
		print(str(pb[2 * i]) + ' ' + str(pb[2 * i + 1]))
else:
	print(-1)


R = lambda : map(int, input().split())
n = int(input())
s1 = input()
s2 = input()
(ab, ba) = ([], [])
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		ab.append(i)
	elif s1[i] == 'b' and s2[i] == 'a':
		ba.append(i)
(l1, l2) = (len(ab), len(ba))
if (l1 + l2) % 2:
	print(-1)
else:
	print((l1 + l2) // 2 + l1 % 2)
	if l1 % 2:
		k = ab.pop()
		print(k + 1, k + 1)
		ba.append(k)
		l1 -= 1
		l2 += 1
	for i in range(0, l1, 2):
		print(ab[i] + 1, ab[i + 1] + 1)
	for i in range(0, l2, 2):
		print(ba[i] + 1, ba[i + 1] + 1)


n = int(input())
s = list(input())
t = list(input())
res = 0
abcount = 0
bacount = 0
abindex = []
baindex = []
opps = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			abcount += 1
			abindex.append(i + 1)
		else:
			bacount += 1
			baindex.append(i + 1)
if abcount % 2 == 0 and bacount % 2 == 0:
	res = abcount // 2 + bacount // 2
	for i in range(0, abcount, 2):
		opps.append([abindex[i], abindex[i + 1]])
	for i in range(0, bacount, 2):
		opps.append([baindex[i], baindex[i + 1]])
elif abcount % 2 == 1 and bacount % 2 == 1:
	res = abcount // 2 + bacount // 2 + 2
	for i in range(0, abcount - 1, 2):
		opps.append([abindex[i], abindex[i + 1]])
	for i in range(0, bacount - 1, 2):
		opps.append([baindex[i], baindex[i + 1]])
	opps.append([baindex[-1], baindex[-1]])
	opps.append([baindex[-1], abindex[-1]])
else:
	res = -1
	opps = []
print(res)
for opp in opps:
	print(' '.join(list(map(str, opp))))


n = int(input())
s = input()
t = input()
a = []
b = []
ba = 0
ab = 0
if (s.count('a') + t.count('a')) % 2 == 1:
	print(-1)
else:
	for i in range(n):
		if s[i] == 'b' and t[i] == 'a':
			ba += 1
			b.append(i + 1)
		elif s[i] == 'a' and t[i] == 'b':
			ab += 1
			a.append(i + 1)
	ans = ba // 2 + ab // 2
	if ba % 2 == 1:
		ans += 2
	print(ans)
	if ba > 1:
		for i in range(0, ba - 1, 2):
			print(b[i], b[i + 1])
	if ab > 1:
		for i in range(0, ab - 1, 2):
			print(a[i], a[i + 1])
	if ba % 2 == 1:
		print(b[ba - 1], b[ba - 1])
		print(b[ba - 1], a[ab - 1])


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
n = INI()
A = INS()
B = INS()
X = []
Y = []
for _ in range(n):
	if A[_] != B[_]:
		if A[_] == 'a':
			X.append(_ + 1)
		else:
			Y.append(_ + 1)
(x, y) = (len(X), len(Y))
if (x + y) % 2 == 1:
	OPS(-1)
elif x % 2 == 0:
	OPS((x + y) // 2)
	for _ in range(x // 2):
		OPL([X[2 * _], X[2 * _ + 1]])
	for _ in range(y // 2):
		OPL([Y[2 * _], Y[2 * _ + 1]])
else:
	OPS(x // 2 + y // 2 + 2)
	for _ in range(x // 2):
		OPL([X[2 * _], X[2 * _ + 1]])
	for _ in range(y // 2):
		OPL([Y[2 * _], Y[2 * _ + 1]])
	OPL([X[-1], X[-1]])
	OPL([X[-1], Y[-1]])


n = int(input())
s = input()
t = input()
l1 = []
l2 = []
l3 = []
l4 = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		l1.append(i)
	elif s[i] == 'b' and t[i] == 'a':
		l2.append(i)
	elif s[i] == t[i] == 'a':
		l3.append(i)
	elif s[i] == t[i] == 'b':
		l4.append(i)
ans = []
flag = True
if len(l1) % 2 == 0 and len(l2) % 2 == 0:
	for i in range(0, len(l1) - 1, 2):
		ans.append((l1[i], l1[i + 1]))
	for i in range(0, len(l2) - 1, 2):
		ans.append((l2[i], l2[i + 1]))
elif (len(l1) + len(l2)) % 2 == 1:
	flag = False
else:
	for i in range(0, len(l2) - 2, 2):
		ans.append((l2[i], l2[i + 1]))
	for i in range(0, len(l1) - 2, 2):
		ans.append((l1[i], l1[i + 1]))
	ans.append((l1[-1], l1[-1]))
	ans.append((l1[-1], l2[-1]))
if flag:
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0] + 1, ans[i][1] + 1)
else:
	print(-1)


from sys import stdin, stdout
n = int(stdin.readline().strip())
s = list(stdin.readline().strip())
s1 = list(stdin.readline().strip())
can = [0 for i in range(26)]
pos1 = [[] for i in range(26)]
pos2 = [[] for j in range(26)]
ab = []
ba = []
for i in range(n):
	can[ord(s[i]) - ord('a')] += 1
	if s[i] == 'a' and s1[i] == 'b':
		ab.append(i)
	if s[i] == 'b' and s1[i] == 'a':
		ba.append(i)
for i in range(n):
	can[ord(s1[i]) - ord('a')] += 1
flag = True
for i in range(26):
	if can[i] % 2 != 0:
		flag = False
		break
if flag == False:
	print(-1)
else:
	op = []
	while len(ab) != 0 or len(ba) != 0:
		if len(ab) > 1:
			op.append([ab[-1] + 1, ab[-2] + 1])
			ab.pop()
			ab.pop()
			continue
		if len(ba) > 1:
			op.append([ba[-1] + 1, ba[-2] + 1])
			ba.pop()
			ba.pop()
			continue
		else:
			op.append([ba[-1] + 1, ba[-1] + 1])
			ab.append(ba[-1])
			ba.pop()
	stdout.write('%d\n' % len(op))
	for i in op:
		stdout.write('%d %d\n' % (i[0], i[1]))


n = int(input())
s1 = input()
s2 = input()
ab = []
ba = []
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		ab.append(i)
	elif s1[i] == 'b' and s2[i] == 'a':
		ba.append(i)
if (len(ab) + len(ba)) % 2:
	print(-1)
else:
	print(len(ab) // 2 + len(ba) // 2 + len(ab) % 2 * 2)
	for i in range(1, len(ab), 2):
		print(ab[i - 1] + 1, ab[i] + 1)
	for i in range(1, len(ba), 2):
		print(ba[i - 1] + 1, ba[i] + 1)
	if len(ab) % 2:
		print(ab[-1] + 1, ab[-1] + 1)
		print(ab[-1] + 1, ba[-1] + 1)


n = int(input())
x = input()
y = input()
ab = []
ba = []
for (i, (xi, yi)) in enumerate(zip(x, y), 1):
	s = xi + yi
	if s == 'ab':
		ab.append(i)
	elif s == 'ba':
		ba.append(i)
if len(ab) % 2 != len(ba) % 2:
	print(-1)
else:
	n1 = len(ab)
	n2 = len(ba)
	print(n1 // 2 + n2 // 2 + (2 if n1 % 2 == 1 else 0))
	for i in range(n1 // 2):
		print(ab[i * 2], ab[i * 2 + 1])
	for i in range(n2 // 2):
		print(ba[i * 2], ba[i * 2 + 1])
	if n1 % 2 == 1:
		print(ab[n1 - 1], ab[n1 - 1])
		print(ab[n1 - 1], ba[n2 - 1])


n = int(input())
s = input()
t = input()

def check(a, b):
	if (len(a) + len(b)) % 2 == 1:
		print(-1)
	else:
		seq = []
		N = 0
		la = len(a) - len(a) % 2
		lb = len(b) - len(b) % 2
		N += la // 2 + lb // 2
		for i in range(0, la // 2):
			seq += [(a[2 * i] + 1, a[2 * i + 1] + 1)]
		for i in range(0, lb // 2):
			seq += [(b[2 * i] + 1, b[2 * i + 1] + 1)]
		la = len(a) - 1
		lb = len(b) - 1
		if la % 2 == 0:
			seq += [(a[la] + 1, a[la] + 1)]
			seq += [(a[la] + 1, b[lb] + 1)]
			N += 2
		print(N)
		for i in range(0, len(seq)):
			print(seq[i][0], seq[i][1])
a = []
b = []
for i in range(0, n):
	if s[i] != t[i]:
		if s[i] == 'a':
			a += [i]
		else:
			b += [i]
check(a, b)


elem = int(input())
string1 = list(input())
string2 = list(input())
wronga = []
wrongb = []
count = 0
check = 0
moves = []
for x in range(elem):
	if string1[x] == string2[x]:
		continue
	elif string1[x] == 'a':
		if len(wronga) > 0:
			count = count + 1
			moves.append(str(wronga[0] + 1) + ' ' + str(x + 1))
			wronga.pop(0)
		else:
			wronga.append(x)
	elif len(wrongb) > 0:
		count = count + 1
		moves.append(str(wrongb[0] + 1) + ' ' + str(x + 1))
		wrongb.pop(0)
	else:
		wrongb.append(x)
if len(wronga) == 1 and len(wrongb) == 1:
	count = count + 2
	moves.append(str(wrongb[0] + 1) + ' ' + str(wrongb[0] + 1))
	moves.append(str(wrongb[0] + 1) + ' ' + str(wronga[0] + 1))
	wronga.pop(0)
	wrongb.pop(0)
if len(wronga) > 0 or len(wrongb) > 0:
	print(-1)
else:
	print(count)
	for x in moves:
		print(x)


n = int(input())
a = [i for i in input()]
b = [i for i in input()]
(ab, ba) = ([], [])
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		ab.append(i)
	if a[i] == 'b' and b[i] == 'a':
		ba.append(i)
x = len(ab) % 2
y = len(ba) % 2
if x + y == 1:
	print(-1)
else:
	u = []
	for i in range(1, len(ab), 2):
		u.append([ab[i] + 1, ab[i - 1] + 1])
	for i in range(1, len(ba), 2):
		u.append([ba[i] + 1, ba[i - 1] + 1])
	if x + y == 2:
		i = ab[-1]
		j = ba[-1]
		u.append([i + 1, i + 1])
		u.append([i + 1, j + 1])
	print(len(u))
	for i in u:
		print(*i)


N = int(input())
S = input()
T = input()
(ab, ba) = ([], [])
for (i, (x, y)) in enumerate(zip(S, T)):
	if x == 'a' and y == 'b':
		ab.append(i + 1)
	if x == 'b' and y == 'a':
		ba.append(i + 1)
if len(ab) < len(ba):
	(ab, ba) = (ba, ab)
(leab, leba) = (len(ab), len(ba))
if (leab - leba) % 2 == 0:
	ans = []
	for i in range((leab - leba) // 2):
		ans.append('%d %d' % (ab[leba + i], ab[leab - i - 1]))
	for i in range(0, leba & ~1, 2):
		ans.append('%d %d' % (ab[i], ab[i + 1]))
		ans.append('%d %d' % (ba[i], ba[i + 1]))
	for i in range(leba & ~1, leba):
		ans.append('%d %d' % (ab[i], ab[i]))
		ans.append('%d %d' % (ab[i], ba[i]))
	print(len(ans))
	print('\n'.join(ans))
else:
	print(-1)


(n, s, t) = (int(input()), input(), input())
ab = []
ba = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	if s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
if (len(ab) + len(ba)) % 2:
	print(-1)
else:
	ans = []
	ans += [(ab[2 * a], ab[2 * a + 1]) for a in range(len(ab) // 2)]
	ans += [(ba[2 * a], ba[2 * a + 1]) for a in range(len(ba) // 2)]
	if len(ab) % 2:
		ans += [(ab[-1], ab[-1]), (ba[-1], ab[-1])]
	print(len(ans))
	print('\n'.join((f'{i[0]} {i[1]}' for i in ans)))


n = int(input())
s1 = input()
s2 = input()
a1 = s1.count('a')
a2 = s2.count('a')
b1 = s2.count('b')
b2 = s2.count('b')
if a1 - a2 & 1 or b1 - b2 & 1:
	print(-1)
	exit()
dab = []
dba = []
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			dab.append(i)
		else:
			dba.append(i)
d = dict()
for i in range(0, len(dab) - 1, 2):
	d.update({dab[i]: dab[i + 1]})
for i in range(0, len(dba) - 1, 2):
	d.update({dba[i]: dba[i + 1]})
ex = []
if len(dba) & 1 and len(dab) & 1:
	print(len(d) + 2)
	print(dab[-1] + 1, dab[-1] + 1)
	print(dab[-1] + 1, dba[-1] + 1)
else:
	print(len(d))
for (key, value) in d.items():
	print(key + 1, value + 1)


n = int(input())
s = list(input())
t = list(input())
lis1 = []
lis2 = []
for i in range(n):
	if s[i] != t[i] and s[i] == 'a' and (t[i] == 'b'):
		lis1.append([0, 0, 0])
		lis1[-1][0] = s[i]
		lis1[-1][1] = t[i]
		lis1[-1][2] = i
	if s[i] != t[i] and s[i] == 'b' and (t[i] == 'a'):
		lis2.append([0, 0, 0])
		lis2[-1][0] = s[i]
		lis2[-1][1] = t[i]
		lis2[-1][2] = i
if (len(lis1) + len(lis2)) % 2:
	print(-1)
else:
	l1 = len(lis1)
	l2 = len(lis2)
	ans = []
	if l1 % 2 and l2 % 2:
		print((l1 + l2) // 2 + 1)
		for i in range(0, l1 - 1, 2):
			ans.append([lis1[i][2] + 1, lis1[i + 1][2] + 1])
		ans.append([lis2[0][2] + 1, lis2[0][2] + 1])
		ans.append([lis1[-1][2] + 1, lis2[0][2] + 1])
		for i in range(1, l2, 2):
			ans.append([lis2[i][2] + 1, lis2[i + 1][2] + 1])
	else:
		print((l1 + l2) // 2)
		for i in range(0, l1, 2):
			ans.append([lis1[i][2] + 1, lis1[i + 1][2] + 1])
		for i in range(0, l2, 2):
			ans.append([lis2[i][2] + 1, lis2[i + 1][2] + 1])
	for i in ans:
		print(*i)


n = int(input())
s = input()
t = input()
lenS = len(s)
ta = []
tb = []
lenTa = lenTb = 0
res = []
for i in range(lenS):
	if s[i] != t[i]:
		if t[i] == 'a':
			ta.append(i)
			lenTa += 1
		else:
			tb.append(i)
			lenTb += 1
while lenTa > 1:
	res.append((ta[-1], ta[-2]))
	ta.pop()
	ta.pop()
	lenTa -= 2
while lenTb > 1:
	res.append((tb[-1], tb[-2]))
	tb.pop()
	tb.pop()
	lenTb -= 2
if lenTa and lenTb:
	res.append((ta[-1], ta[-1]))
	res.append((ta[-1], tb[-1]))
	print(len(res))
	for i in res:
		print(i[0] + 1, i[1] + 1)
elif lenTa or lenTb:
	print(-1)
else:
	print(len(res))
	for i in res:
		print(i[0] + 1, i[1] + 1)


def main():
	n = int(input())
	s = input()
	t = input()
	upper_a = []
	upper_b = []
	inversions = []
	for i in range(n):
		if s[i] != t[i]:
			inversions.append(i + 1)
			if s[i] == 'a':
				upper_a.append(i + 1)
			else:
				upper_b.append(i + 1)
	if len(inversions) % 2 != 0:
		print(-1)
		return
	ans = []
	while upper_a:
		if len(upper_a) >= 2:
			i = upper_a.pop()
			j = upper_a.pop()
			ans.append((i, j))
		else:
			break
	while upper_b:
		if len(upper_b) >= 2:
			i = upper_b.pop()
			j = upper_b.pop()
			ans.append((i, j))
		else:
			break
	if upper_a:
		i = upper_a.pop()
		j = upper_b.pop()
		ans.append((i, i))
		ans.append((i, j))
	print(len(ans))
	for i in ans:
		print(i[0], i[1])
main()


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
s = input()
t = input()
n = len(s)
id = {'a': 1, 'b': 0}
ind = []
for i in range(n):
	if s[i] == t[i]:
		ok = True
	else:
		ind.append((id[s[i]], i + 1))
ind.sort()
ans = []
if len(ind) % 2:
	print(-1)
	exit()
else:
	for i in range(0, len(ind), 2):
		first = ind[i][0]
		second = ind[i + 1][0]
		ind1 = ind[i][1]
		ind2 = ind[i + 1][1]
		if first == second:
			ans.append((ind1, ind2))
		else:
			ans.append((ind2, ind2))
			ans.append((ind1, ind2))
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
s1 = input().strip()
s2 = input().strip()
a1 = s1.count('a')
b1 = s1.count('b')
a2 = s2.count('a')
b2 = s2.count('b')
if (a1 + a2) % 2 == 0 and (b1 + b2) % 2 == 0:
	ab = []
	ba = []
	for i in range(n):
		if s1[i] == 'a' and s2[i] == 'b':
			ab.append(i + 1)
		elif s1[i] == 'b' and s2[i] == 'a':
			ba.append(i + 1)
	l1 = len(ab)
	l2 = len(ba)
	ans = l1 // 2 + l2 // 2
	ansList = []
	for i in range(0, l1, 2):
		if i + 1 <= l1 - 1:
			ansList.append([ab[i], ab[i + 1]])
	for i in range(0, l2, 2):
		if i + 1 <= l2 - 1:
			ansList.append([ba[i], ba[i + 1]])
	if l1 % 2 == 1 and l2 % 2 == 1:
		ansList.append([ab[-1], ab[-1]])
		ansList.append([ab[-1], ba[-1]])
		ans += 2
	print(ans)
	for i in range(ans):
		print(*ansList[i])
else:
	print(-1)


n = int(input())
s = input()
t = input()
res = {'ab': [], 'ba': []}
for i in range(n):
	if s[i] != t[i]:
		res[s[i] + t[i]].append(i)
r1 = len(res['ab'])
r2 = len(res['ba'])
l1 = r1 + r2
if l1 % 2 == 0:
	val = r1 // 2 + r2 // 2 + r1 % 2 + r2 % 2
	print(val)
	for i in range(1, r1, 2):
		print(res['ab'][i - 1] + 1, res['ab'][i] + 1)
	for i in range(1, r2, 2):
		print(res['ba'][i - 1] + 1, res['ba'][i] + 1)
	if r1 % 2 == 1:
		i = res['ab'][-1]
		j = res['ba'][-1]
		print(i + 1, i + 1)
		print(i + 1, j + 1)
else:
	print(-1)


n = int(input())
s = input()
t = input()
b_a = 0
ba = []
a_b = 0
ab = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		a_b += 1
		ab.append(i)
	if s[i] == 'b' and t[i] == 'a':
		b_a += 1
		ba.append(i)
ans = -1
if a_b % 2 == b_a % 2:
	ans = a_b // 2 + b_a // 2
	ans += 2 * (a_b % 2)
	print(ans)
	for i in range(1, len(ab), 2):
		print(ab[i - 1] + 1, ab[i] + 1)
	for i in range(1, len(ba), 2):
		print(ba[i - 1] + 1, ba[i] + 1)
	if a_b % 2 != 0:
		print(ab[-1] + 1, ab[-1] + 1)
		print(ab[-1] + 1, ba[-1] + 1)
if ans == -1:
	print(ans)


n = int(input())
s = input()
t = input()
ab = 0
abs_ = set()
ba = 0
bas = set()
for i in range(n):
	ss = s[i]
	tt = t[i]
	if ss != tt:
		if ss == 'a':
			ab += 1
			abs_.add(i + 1)
		else:
			ba += 1
			bas.add(i + 1)
if (ab + ba) % 2 != 0:
	print(-1)
	exit(0)
res = []
if len(abs_) % 2 == 1:
	first = abs_.pop()
	second = bas.pop()
	res.append((first, first))
	res.append((first, second))
while abs_:
	first = abs_.pop()
	second = abs_.pop()
	res.append((first, second))
while bas:
	first = bas.pop()
	second = bas.pop()
	res.append((first, second))
print(len(res))
for (x, y) in res:
	print(x, y)


n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] == t[i]:
		continue
	elif s[i] == 'a':
		ab.append(i)
	else:
		ba.append(i)
if (len(ab) + len(ba)) % 2 == 0:
	ans = []
	for i in range(len(ab) // 2):
		ans.append([ab[2 * i], ab[2 * i + 1]])
	for i in range(len(ba) // 2):
		ans.append([ba[2 * i], ba[2 * i + 1]])
	if len(ab) % 2 != 0:
		ans.append([ab[-1], ab[-1]])
		ans.append([ab[-1], ba[-1]])
	print(len(ans))
	for (i, j) in ans:
		print(i + 1, j + 1)
else:
	print(-1)


n = int(input())
s1 = list(input())
s2 = list(input())
(ab, ba) = ([], [])
for i in range(n):
	if s1[i] + s2[i] == 'ab':
		ab.append(i + 1)
	elif s1[i] + s2[i] == 'ba':
		ba.append(i + 1)
if len(ab) & 1 != len(ba) & 1:
	print(-1)
	exit()
ret = []
for i in range(0, len(ab) - 1, 2):
	ret.append('%d %d' % (ab[i], ab[i + 1]))
for i in range(0, len(ba) - 1, 2):
	ret.append('%d %d' % (ba[i], ba[i + 1]))
if len(ab) & 1 == 1:
	ret.extend(('%d %d' % (ab[-1], ab[-1]), '%d %d' % (ab[-1], ba[-1])))
print('%d\n%s' % (len(ret), '\n'.join(ret)))


n = int(input())
s = list(input())
t = list(input())
dic = {'a,b': [], 'b,a': []}
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			dic['a,b'].append(i)
		else:
			dic['b,a'].append(i)
l1 = len(dic['a,b'])
l2 = len(dic['b,a'])
if (l1 + l2) % 2 != 0:
	print(-1)
else:
	if l1 % 2 != 0:
		print((l1 + l2) // 2 + 1)
		print(dic['b,a'][-1] + 1, dic['b,a'][-1] + 1)
		dic['a,b'].append(dic['b,a'][-1])
		del dic['b,a'][-1]
		l1 += 1
		l2 -= 1
	else:
		print((l1 + l2) // 2)
	if l2 != 0:
		for i in range(0, l2, 2):
			print(dic['b,a'][i] + 1, dic['b,a'][i + 1] + 1)
	if l1 != 0:
		for i in range(0, l1, 2):
			print(dic['a,b'][i] + 1, dic['a,b'][i + 1] + 1)


import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()
mismatched = []

def solve():
	sma = []
	smb = []
	sa = 0
	ta = 0
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				sa += 1
				sma.append(i)
			else:
				ta += 1
				smb.append(i)
		elif s[i] == 'a':
			sa += 1
			ta += 1
	if (sa + ta) % 2:
		return -1
	ans = []
	while sma:
		idx = sma.pop()
		if sma:
			rev_idx = sma.pop()
			ans.append((rev_idx, idx))
		else:
			ans.append((idx, idx))
			smb.append(idx)
	while smb:
		idx = smb.pop()
		rev_idx = smb.pop()
		ans.append((rev_idx, idx))
	return ans
ret = solve()
if ret == -1:
	print(-1)
else:
	print(len(ret))
	for ele in ret:
		print(ele[0] + 1, ele[1] + 1)


import sys
n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()
A = []
B = []
C = []
D = []
(a, b, c, d) = (0, 0, 0, 0)
for i in range(0, n):
	if s[i] == 'a' and t[i] == 'a':
		a = a + 1
		A.append(i)
	if s[i] == 'a' and t[i] == 'b':
		c = c + 1
		C.append(i)
	if s[i] == 'b' and t[i] == 'a':
		d = d + 1
		D.append(i)
	if s[i] == 'b' and t[i] == 'b':
		b = b + 1
		B.append(i)
if (c + d) % 2 != 0:
	print(-1)
else:
	print((c + 1) // 2 + (d + 1) // 2)
	lc = len(C)
	ld = len(D)
	while lc >= 2:
		print(str(C[lc - 1] + 1) + ' ' + str(C[lc - 2] + 1))
		lc = lc - 2
		B.append(lc - 1)
		A.append(lc - 2)
	while ld >= 2:
		print(str(D[ld - 1] + 1) + ' ' + str(D[ld - 2] + 1))
		ld = ld - 2
		A.append(ld - 1)
		B.append(ld - 2)
	if lc == ld == 1:
		print(str(C[0] + 1) + ' ' + str(C[0] + 1))
		print(str(C[0] + 1) + ' ' + str(D[0] + 1))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
str1 = [ord(k) - 97 for k in input()]
str2 = [ord(k) - 97 for k in input()]
ab = 0
indab = []
ba = 0
indba = []
a = 0
b = 0
for s in range(n):
	if str1[s] != str2[s]:
		if str1[s] == ord('a') - 97:
			ab += 1
			indab.append(s + 1)
		else:
			ba += 1
			indba.append(s + 1)
		a += 1
		b += 1
	elif str1[s] == 'a':
		a += 2
	else:
		b += 2
if a % 2 == 0 and b % 2 == 0:
	ans = 0
	inds = []
	if ab % 2 == 1 and ba % 2 == 1:
		ans += 2
		ind1 = indab.pop()
		ind2 = indba.pop()
		inds.append((ind1, ind1))
		inds.append((ind1, ind2))
	while len(indab) > 0:
		ind1 = indab.pop()
		ind2 = indab.pop()
		inds.append((ind1, ind2))
		ans += 1
	while len(indba) > 0:
		ind1 = indba.pop()
		ind2 = indba.pop()
		inds.append((ind1, ind2))
		ans += 1
	print(ans)
	for s in range(len(inds)):
		print(*inds[s])
else:
	print(-1)


n = int(input())
(s1, s2) = (input(), input())
diff = {'ab': [], 'ba': []}
cnt = 0
for i in range(n):
	cnt += 1 if s1[i] == 'a' else 0
	cnt += 1 if s2[i] == 'a' else 0
	if s1[i] != s2[i]:
		diff[s1[i] + s2[i]].append(i + 1)
if cnt % 2:
	print(-1)
else:
	swaps = []
	(lenAB, lenBA) = (len(diff['ab']), len(diff['ba']))
	while lenAB > 1:
		swaps.append((diff['ab'][lenAB - 2], diff['ab'][lenAB - 1]))
		lenAB -= 2
	while lenBA > 1:
		swaps.append((diff['ba'][lenBA - 2], diff['ba'][lenBA - 1]))
		lenBA -= 2
	for (i, j) in zip(diff['ab'][:lenAB], diff['ba'][:lenBA]):
		swaps.append((i, i))
		swaps.append((i, j))
	print(len(swaps))
	for i in swaps:
		print(*i)


import sys
n = int(input())
s = input()
t = input()
if (s.count('a') + t.count('a')) % 2 or (s.count('b') + t.count('b')) % 2:
	print(-1)
	sys.exit(0)
(ab, ba) = (0, 0)
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab += 1
	if s[i] == 'b' and t[i] == 'a':
		ba += 1
(pab, pba) = (-1, -1)
mvs = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		if pab != -1:
			mvs.append((i, pab))
			pab = -1
		else:
			pab = i
	if s[i] == 'b' and t[i] == 'a':
		if pba != -1:
			mvs.append((i, pba))
			pba = -1
		else:
			pba = i
if pab != -1:
	mvs.append((pab, pab))
	mvs.append((pab, pba))
print(len(mvs))
for (a, b) in mvs:
	print(a + 1, b + 1)


n = int(input())
(s, t) = (input(), input())
mm = [i for i in enumerate(zip(s, t)) if i[1][0] != i[1][1]]
mmc = len(mm)
if mmc % 2:
	print(-1)
else:
	c1 = [a for a in mm if a[1] == ('a', 'b')]
	c2 = [a for a in mm if a[1] == ('b', 'a')]
	lc1 = len(c1)
	lc2 = len(c2)
	if lc1 < lc2:
		(lc1, lc2) = (lc2, lc1)
		(c1, c2) = (c2, c1)
	print(lc1 // 2 + lc2 // 2 + 2 * (lc1 % 2))
	i = 0
	while i < lc1 - lc1 % 2:
		print(c1[i][0] + 1, c1[i + 1][0] + 1)
		i += 2
	i = 0
	while i < lc2 - lc1 % 2:
		print(c2[i][0] + 1, c2[i + 1][0] + 1)
		i += 2
	if lc1 % 2:
		print(c1[-1][0] + 1, c1[-1][0] + 1)
		print(c1[-1][0] + 1, c2[-1][0] + 1)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	n = iin()
	s = sin()
	t = sin()
	c = [0] * 26
	for i in range(n):
		c[ord(s[i]) - 97] += 1
		c[ord(t[i]) - 97] += 1
	for i in c:
		if i % 2 != 0:
			print(-1)
			sys.exit(0)
	d = {}
	for i in range(n):
		if s[i] != t[i]:
			if (s[i], t[i]) in d:
				d[s[i], t[i]][0].append(i + 1)
				d[s[i], t[i]][1] += 1
			else:
				d[s[i], t[i]] = [deque([i + 1]), 1]
	ans = deque([])
	for (k, v) in d.items():
		i = 0
		while i < v[1] - 1:
			ans.append([v[0].popleft(), v[0].popleft()])
			i += 2
		d[k][1] = v[1] % 2
	for k in d.keys():
		if d[k][1] == 1:
			(a, b) = k
			if (b, a) in d and d[b, a][1] == 1:
				x1 = d[k][0].pop()
				x2 = d[b, a][0].pop()
				ans.append([x1, x1])
				ans.append([x1, x2])
				d[k][1] -= 1
				d[b, a][1] -= 1
			else:
				print(-1)
				sys.exit()
	print(len(ans))
	for k in ans:
		print(*k)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	n = int(input())
	s1 = input()
	s2 = input()
	f = []
	s = []
	ind = []
	d = {'a': 0, 'b': 0}
	for i in range(n):
		if s2[i] != s1[i]:
			f.append(s1[i])
			s.append(s2[i])
			ind.append(i)
			d[s1[i]] += 1
	if d['a'] % 2 == 0 and d['b'] % 2 == 0:
		k = []
		for i in range(len(f)):
			k.append([f[i], ind[i]])
		k.sort()
		print(len(k) // 2)
		for i in range(0, len(k), 2):
			print(k[i][1] + 1, k[i + 1][1] + 1)
	elif d['a'] % 2 == 1 and d['b'] % 2 == 1:
		k = []
		for i in range(len(f)):
			k.append([f[i], ind[i]])
		k.sort()
		print(len(k) // 2 + 1)
		print(k[0][1] + 1, k[0][1] + 1)
		k[0][0] = 'b'
		k.sort()
		for i in range(0, len(k), 2):
			print(k[i][1] + 1, k[i + 1][1] + 1)
	else:
		print(-1)
	return
main()


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = list(input())
	t = list(input())
	(l, r) = (0, 0)
	ans = 0
	arr = []
	z = l
	while l < n:
		while s[l] == t[l]:
			l += 1
			if l == n:
				break
		if l == n:
			break
		z = l
		r = l + 1
		while True:
			if r == n:
				ans = -1
				break
			if s[r] == t[r]:
				pass
			elif s[l] == s[r]:
				break
			elif z == l:
				z = r
			r += 1
		if ans == -1 and z == l:
			break
		elif ans == -1:
			(s[z], t[z]) = (t[z], s[z])
			arr.append([z + 1, z + 1])
			(s[l], t[z]) = (t[z], s[l])
			arr.append([l + 1, z + 1])
			l = z + 1
			ans += 1
		else:
			(s[l], t[r]) = (t[r], s[l])
			arr.append([l + 1, r + 1])
			ans += 1
			if z == l:
				l = r + 1
			else:
				l = z
			if l == n:
				break
	if ans != -1:
		print(len(arr))
		for item in arr:
			print(*item)
	else:
		print(ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


n = int(input())
s = input()
k = input()
r = []
l = []
for i in range(n):
	if s[i] + k[i] == 'ba':
		r.append(i + 1)
	elif s[i] + k[i] == 'ab':
		l.append(i + 1)
p = len(r) + len(l)
if p % 2 == 0:
	if len(r) % 2 == 0:
		print(p // 2)
		r = r + l
		for i in range(0, p, 2):
			print(r[i], r[i + 1])
	else:
		print(p // 2 + 1)
		print(r[0], r[0])
		print(r[0], l[0])
		r = r[1:] + l[1:]
		for i in range(0, p - 2, 2):
			print(r[i], r[i + 1])
else:
	print('-1')


from sys import *
input = stdin.readline
from bisect import *
import math
from collections import *
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7

def check():
	cnt = Counter(s + t)
	for i in cnt:
		if cnt[i] % 2:
			return 1
	return 0
n = int(input())
s = list(input())[:-1]
t = list(input())[:-1]
if check():
	print(-1)
else:
	ans = []
	dic = defaultdict(int)
	si = defaultdict(list)
	ti = defaultdict(list)
	for i in range(n):
		if s[i] == t[i]:
			continue
		if len(si[s[i]]):
			ans.append((si[s[i]][-1], i + 1))
			si[s[i]].pop()
		else:
			si[s[i]].append(i + 1)
			ti[t[i]].append(i + 1)
	if len(si['a']):
		ans.append((si['a'][-1], si['a'][-1]))
		ans.append((si['a'][-1], ti['a'][-1]))
	print(len(ans))
	for i in ans:
		print(*i)


import bisect

def readInt():
	x = int(input())
	return x

def readList():
	x = map(int, input().split(' '))
	return list(x)
tx = readInt()
s = input()
t = input()
(sa, sb) = (s.count('a'), s.count('b'))
(ta, tb) = (t.count('a'), t.count('b'))
if (ta + sa) % 2 == (tb + sb) % 2 and (ta + sa) % 2 == 0:
	(vab, vba) = ([], [])
	(ab, ba) = (0, 0)
	for i in range(tx):
		if s[i] == 'a' and t[i] == 'b':
			ab += 1
			vab.append(i)
		elif t[i] == 'a' and s[i] == 'b':
			ba += 1
			vba.append(i)
		else:
			continue
	swaps = ab // 2 + ba // 2
	ab %= 2
	ba %= 2
	swaps += ab + ba
	print(swaps)
	if len(vab) % 2 == 0:
		for i in range(0, len(vab), 2):
			print(vab[i] + 1, vab[i + 1] + 1)
		for i in range(0, len(vba), 2):
			print(vba[i] + 1, vba[i + 1] + 1)
	else:
		for i in range(0, len(vab) - 1, 2):
			print(vab[i] + 1, vab[i + 1] + 1)
		for i in range(0, len(vba) - 1, 2):
			print(vba[i] + 1, vba[i + 1] + 1)
		(lvab, lvba) = (len(vab), len(vba))
		print(vab[lvab - 1] + 1, vab[lvab - 1] + 1)
		print(vab[lvab - 1] + 1, vba[lvba - 1] + 1)
else:
	print('-1')


from sys import exit
n = int(input())
s1 = input()
s2 = input()
if (s1.count('a') + s2.count('a')) % 2 == 1 or (s1.count('b') + s2.count('b')) % 2 == 1:
	print(-1)
	exit(0)
sort1 = []
sort2 = []
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			sort1.append(i)
		else:
			sort2.append(i)
moves = []
while len(sort1) > 1:
	moves.append([sort1[-1], sort1[-2]])
	sort1.pop()
	sort1.pop()
while len(sort2) > 1:
	moves.append([sort2[-1], sort2[-2]])
	sort2.pop()
	sort2.pop()
if len(sort1) == 1:
	moves.append([sort1[0], sort1[0]])
	moves.append([sort1[0], sort2[0]])
print(len(moves))
for x in moves:
	print(x[0] + 1, x[1] + 1)


n = int(input())
s = input().rstrip()
S = input().rstrip()
x = list(s)
y = list(S)
l = []
q = []
w = []
S = []
D = []
X = 0
Y = 0
for i in range(0, len(x)):
	if x[i] == 'a':
		X += 1
	else:
		Y += 1
	if y[i] == 'a':
		X += 1
	else:
		Y += 1
if X % 2 != 0 or Y % 2 != 0:
	print(-1)
else:
	M = 0
	F = 0
	G = []
	H = []
	for i in range(0, len(x)):
		if x[i] != y[i]:
			if x[i] == 'a':
				l.append(i)
			else:
				w.append(i)
	i = 0
	while i < len(x):
		if x[i] != y[i]:
			F += 1
			if x[i] == 'b':
				A = w[len(w) - 1]
				temp = x[i]
				x[i] = y[A]
				y[A] = temp
				del w[len(w) - 1]
				G.append(i + 1)
				G.append(A + 1)
				if x[i] != y[i]:
					continue
			else:
				A = l[len(l) - 1]
				temp = x[i]
				x[i] = y[A]
				y[A] = temp
				del l[len(l) - 1]
				G.append(i + 1)
				G.append(A + 1)
				if x[i] != y[i]:
					continue
		i += 1
	print(F)
	for i in range(0, len(G), 2):
		print(G[i], G[i + 1])


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
s = input()
t = input()
x = s.count('a')
y = t.count('a')
if not ((x + y) % 2 == 0 and (2 * n - x - y) % 2 == 0):
	print('-1')
	return
ab = []
ba = []
for i in range(n):
	if s[i] == t[i]:
		continue
	elif s[i] == 'a':
		ab.append(i + 1)
	else:
		ba.append(i + 1)
ans = []
while len(ab) >= 2:
	(x, y) = (ab.pop(), ab.pop())
	ans.append((x, y))
while len(ba) >= 2:
	(x, y) = (ba.pop(), ba.pop())
	ans.append((x, y))
if len(ab) + len(ba) == 0:
	print(len(ans))
	for i in ans:
		print(*i)
else:
	x = ab[0]
	y = ba[0]
	ans.append((x, x))
	ans.append((x, y))
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
s = input()
t = input()
aa = []
ab = []
ba = []
bb = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'a':
		aa.append(i)
	elif s[i] == 'a' and t[i] == 'b':
		ab.append(i)
	if s[i] == 'b' and t[i] == 'a':
		ba.append(i)
	if s[i] == 'b' and t[i] == 'b':
		bb.append(i)
if len(ab) == 0 and len(ba) == 0:
	print(0)
	exit(0)
if len(ab) % 2 == 1 and len(ba) % 2 == 0:
	print(-1)
	exit(0)
if len(ab) % 2 == 0 and len(ba) % 2 == 1:
	print(-1)
	exit(0)
swaps = []
for i in range(1, len(ab), 2):
	swaps.append((ab[i - 1], ab[i]))
	bb.append(ab[i - 1])
	aa.append(ab[i])
for i in range(1, len(ba), 2):
	swaps.append((ba[i - 1], ba[i]))
	aa.append(ba[i - 1])
	bb.append(ba[i])
if len(ab) % 2 == 1:
	i = ab[-1]
	j = ba[-1]
	swaps.append((j, j))
	swaps.append((i, j))
print(len(swaps))
for swap in swaps:
	print(swap[0] + 1, swap[1] + 1)


n = int(input())
s = input()
t = input()
if (s.count('a') + t.count('a')) % 2 != 0:
	print(-1)
	exit()
a = []
b = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			a += [i]
		else:
			b += [i]
swaps = len(a) // 2 + len(b) // 2
swaps += len(a) % 2 * 2
print(swaps)
for i in range(len(a) // 2):
	print(a[2 * i] + 1, a[2 * i + 1] + 1)
for i in range(len(b) // 2):
	print(b[2 * i] + 1, b[2 * i + 1] + 1)
if len(a) % 2 != 0:
	print(a[-1] + 1, a[-1] + 1)
	print(a[-1] + 1, b[-1] + 1)


n = int(input())
a = input()
b = input()
f = 1
ia = []
ib = []
cnt = [0] * 26
for i in range(n):
	cnt[ord(a[i]) - 97] += 1
	cnt[ord(b[i]) - 97] += 1
for i in range(26):
	if cnt[i] % 2 == 1:
		f = 0
		break
if f == 0:
	print(-1)
else:
	for i in range(1, n + 1):
		if a[i - 1] != b[i - 1] and a[i - 1] == 'a':
			ia.append(i)
		elif a[i - 1] != b[i - 1] and a[i - 1] == 'b':
			ib.append(i)
	ans = len(ia) // 2 + len(ib) // 2
	a1 = 0
	a2 = 0
	if len(ia) % 2 == 1:
		a1 = ia[-1]
		a2 = ib[-1]
		ans += 2
		print(ans)
		print(a2, a2)
		print(a1, a2)
	else:
		print(ans)
	i = 0
	l = 0
	while i < len(ia) // 2:
		print(ia[l], ia[l + 1])
		l += 2
		i += 1
	i = 0
	l = 0
	while i < len(ib) // 2:
		print(ib[l], ib[l + 1])
		i += 1
		l += 2


n = int(input())
s = input()
t = input()
if (s.count('a') + t.count('a')) % 2 != 0 or (s.count('b') + t.count('b')) % 2 != 0:
	print(-1)
else:
	a = []
	b = []
	r = 0
	for i in range(n):
		if s[i] == 'a' and t[i] == 'b':
			a.append(i)
		elif s[i] == 'b' and t[i] == 'a':
			b.append(i)
	q = []
	while len(a) > 1:
		c1 = a.pop()
		c2 = a.pop()
		q.append((c1 + 1, c2 + 1))
		r += 1
	while len(b) > 1:
		c1 = b.pop()
		c2 = b.pop()
		q.append((c1 + 1, c2 + 1))
		r += 1
	if a:
		c1 = a.pop()
		c2 = b.pop()
		q.append((c1 + 1, c1 + 1))
		q.append((c1 + 1, c2 + 1))
		r += 2
	print(r)
	for i in q:
		print(*i)


(a1, a2) = (0, 0)
l1 = []
l2 = []
n = int(input())
s1 = input()
s2 = input()
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			l1.append(i + 1)
			a1 += 1
		else:
			a2 += 1
			l2.append(i + 1)
if (a1 + a2) % 2:
	print(-1)
elif s1 == s2:
	print(0)
else:
	an = 0
	l3 = []
	if a1 % 2:
		an += 1
		l3.append([l2[0], l2[0]])
		l1.append(l2[0])
		if len(l2) == 1:
			l2 = []
		else:
			l2 = l2[1:]
	an += (a1 + a2) // 2
	l = l1 + l2
	for i in range(0, len(l), 2):
		l3.append([l[i], l[i + 1]])
	print(an)
	for i in l3:
		print(*i)


n = int(input())
s = list(input())
t = list(input())
u_a = []
u_b = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			u_a.append(i)
		else:
			u_b.append(i)
p = len(u_a)
q = len(u_b)
if (p + q) % 2 != 0:
	print(-1)
else:
	k = p // 2 + q // 2
	if p % 2 != 0:
		k += 2
	print(k)
	if p % 2 != 0:
		k += 2
		print(u_a[p - 1] + 1, u_a[p - 1] + 1)
		print(u_a[p - 1] + 1, u_b[q - 1] + 1)
		p -= 1
		q -= 1
	if p:
		for i in range(0, p, 2):
			print(u_a[i] + 1, u_a[i + 1] + 1)
	if q:
		for i in range(0, q, 2):
			print(u_b[i] + 1, u_b[i + 1] + 1)


n = int(input())
s = input()
t = input()
if s == t:
	print(0)
	exit()
cnta = s.count('a') + t.count('a')
cntb = s.count('b') + t.count('b')
if cnta % 2 != 0 or cntb % 2 != 0:
	print(-1)
	exit()
else:
	ab = []
	ba = []
	for i in range(n):
		if s[i] == 'a' and t[i] == 'b':
			ab.append(i)
		if s[i] == 'b' and t[i] == 'a':
			ba.append(i)
	if len(ab) % 2 == 0 and len(ba) % 2 != 0 or (len(ab) % 2 != 0 and len(ba) % 2 == 0):
		print(-1)
		exit()
	if len(ab) % 2 == 0 and len(ba) % 2 == 0:
		ans = len(ab) // 2 + len(ba) // 2
		l = []
		i = 0
		while i < len(ab):
			l.append((ab[i] + 1, ab[i + 1] + 1))
			i += 2
		i = 0
		while i < len(ba):
			l.append((ba[i] + 1, ba[i + 1] + 1))
			i += 2
		print(ans)
		for i in l:
			print(*i)
	else:
		ans = len(ab) // 2 + len(ba) // 2
		l = []
		i = 0
		while i < len(ab) - 1:
			l.append((ab[i] + 1, ab[i + 1] + 1))
			i += 2
		i = 0
		while i < len(ba) - 1:
			l.append((ba[i] + 1, ba[i + 1] + 1))
			i += 2
		l.append((ab[-1] + 1, ab[-1] + 1))
		l.append((ab[-1] + 1, ba[-1] + 1))
		print(ans + 2)
		for i in l:
			print(*i)


from collections import deque
n = int(input())
s = list(input())
t = list(input())
a = deque([])
b = deque([])
diff = 0
x = []
for i in range(n):
	if s[i] != t[i]:
		diff += 1
		x.append(i)
if diff % 2 != 0:
	print(-1)
elif diff == 2:
	print(2)
	print(x[0] + 1, x[0] + 1)
	print(x[0] + 1, x[1] + 1)
else:
	for i in range(0, n):
		if t[i] != s[i]:
			if t[i] == 'a':
				a.append(i)
			else:
				b.append(i)
	total = 0
	steps = []
	for i in range(0, len(a) // 2):
		steps.append((a[i] + 1, a[len(a) - 1 - i] + 1))
	for i in range(0, len(b) // 2):
		steps.append((b[i] + 1, b[len(b) - 1 - i] + 1))
	if len(a) % 2 == len(b) % 2 == 1:
		steps.append((a[len(a) // 2] + 1, a[len(a) // 2] + 1))
		steps.append((a[len(a) // 2] + 1, b[len(b) // 2] + 1))
	print(len(steps))
	for i in steps:
		print(*i)


n = int(input())
s1 = input()
s2 = input()
z1 = []
z2 = []
if (s1.count('a') + s2.count('a')) % 2 != 0 and (s1.count('b') + s2.count('b')) % 2 != 0:
	print(-1)
	exit()
yo = []
for i in range(n):
	if s1[i] == 'b' and s2[i] == 'a':
		z1.append(i)
	elif s1[i] == 'a' and s2[i] == 'b':
		z2.append(i)
za1 = z1[:len(z1) // 2 * 2]
za2 = z2[:len(z2) // 2 * 2]
z1 = z1[len(z1) // 2 * 2:]
z2 = z2[len(z2) // 2 * 2:]
if len(z1) != len(z2):
	print(-1)
	exit()
print(len(z1) * 2 + len(za1) // 2 + len(za2) // 2)
for i in range(0, len(za1), 2):
	print(za1[i] + 1, za1[i + 1] + 1)
for i in range(0, len(za2), 2):
	print(za2[i] + 1, za2[i + 1] + 1)
for i in range(len(z1)):
	print(z1[i] + 1, z1[i] + 1)
	print(z1[i] + 1, z2[i] + 1)


from collections import defaultdict as dd
n = int(input())
s = input()
ss = input()
d = dd(list)
for i in range(n):
	sss = s[i] + ss[i]
	d[sss].append(i + 1)
ll = []
res = 0
lol = 0
if len(d['ab']) % 2 == 0 and len(d['ba']) % 2 == 1 or (len(d['ba']) % 2 == 0 and len(d['ab']) % 2 == 1):
	lol = 1
elif len(d['ab']) % 2 == 0:
	for i in range(0, len(d['ab']), 2):
		ll.append((d['ab'][i], d['ab'][i + 1]))
		res += 1
	for i in range(0, len(d['ba']), 2):
		ll.append((d['ba'][i], d['ba'][i + 1]))
		res += 1
else:
	for i in range(0, len(d['ab']) - 1, 2):
		ll.append((d['ab'][i], d['ab'][i + 1]))
		res += 1
	for i in range(0, len(d['ba']) - 1, 2):
		ll.append((d['ba'][i], d['ba'][i + 1]))
		res += 1
	res += 2
	ll.append((d['ab'][-1], d['ab'][-1]))
	ll.append((d['ab'][-1], d['ba'][-1]))
if lol == 1:
	print(-1)
else:
	print(res)
	for i in ll:
		print(*i)


n = int(input())
a = input()
b = input()
ab_pa = []
ba_pa = []
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		ab_pa.append(i)
	elif a[i] == 'b' and b[i] == 'a':
		ba_pa.append(i)
ans = list()
for i in range(0, len(ba_pa), 2):
	if i + 1 < len(ba_pa):
		ans.append([ba_pa[i] + 1, ba_pa[i + 1] + 1])
for i in range(0, len(ab_pa), 2):
	if i + 1 < len(ab_pa):
		ans.append([ab_pa[i] + 1, ab_pa[i + 1] + 1])
p = len(ab_pa) % 2
q = len(ba_pa) % 2
if p == q:
	if p == q == 1:
		ans.append([ab_pa[-1] + 1, ab_pa[-1] + 1])
		ans.append([ab_pa[-1] + 1, ba_pa[-1] + 1])
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])
else:
	print(-1)


import sys
input = sys.stdin.readline
n = int(input())
s1 = input().strip()
s2 = input().strip()
(l1, l2, ans) = ([], [], [])
for i in range(n):
	if s1[i] == s2[i]:
		continue
	elif s1[i] == 'a' and s2[i] == 'b':
		l1.append(i)
	elif s1[i] == 'b' and s2[i] == 'a':
		l2.append(i)
if len(l1) & 1 == len(l2) & 1:
	while len(l1) >= 2:
		a = l1.pop()
		b = l1.pop()
		ans.append((a + 1, b + 1))
	while len(l2) >= 2:
		a = l2.pop()
		b = l2.pop()
		ans.append((a + 1, b + 1))
	while l1 and l2:
		a = l1.pop()
		b = l2.pop()
		ans.append((a + 1, a + 1))
		ans.append((a + 1, b + 1))
	print(len(ans))
	for i in ans:
		print(*i)
else:
	print(-1)


def main():
	n = int(input())
	s1 = str(input())
	s2 = str(input())
	if s1 == s2:
		print(0)
		return
	a = []
	b = []
	cnt = 0
	for i in range(n):
		if s1[i] != s2[i]:
			cnt += 1
			if s1[i] == 'a':
				a.append(i + 1)
			else:
				b.append(i + 1)
	if cnt % 2:
		print(-1)
		return
	if len(a) % 2:
		print((len(a) + len(b)) // 2 + 1)
	else:
		print((len(a) + len(b)) // 2)
	for i in range(0, len(a) - len(a) % 2, 2):
		print(a[i], a[i + 1])
	for i in range(0, len(b) - len(b) % 2, 2):
		print(b[i], b[i + 1])
	if len(a) % 2 != 0:
		print(a[-1], a[-1])
		print(a[-1], b[-1])
	return
main()


n = int(input())
s = input().strip()
t = input().strip()
ia = []
ib = []
for i in range(n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ia.append([i, s[i]])
		else:
			ib.append([i, s[i]])
if (len(ia) + len(ib)) % 2 == 1:
	print(-1)
else:
	ans = 0
	ww = -1
	if len(ia) % 2 == 1:
		w = ia.pop()
		w[1] = 'b'
		ib.append(w)
		ans = 1
		ww = w[0]
	ans += len(ia) // 2 + len(ib) // 2
	print(ans)
	if ww != -1:
		print(ww + 1, ww + 1)
	for i in range(0, len(ia), 2):
		print(ia[i][0] + 1, ia[i + 1][0] + 1)
	for i in range(0, len(ib), 2):
		print(ib[i][0] + 1, ib[i + 1][0] + 1)


n = int(input())
s = list(input())
t = list(input())
counta = 0
countb = 0
for i in range(n):
	if s[i] == 'a':
		counta += 1
	else:
		countb += 1
	if t[i] == 'a':
		counta += 1
	else:
		countb += 1
if counta % 2 or countb % 2:
	print(-1)
else:
	ab = []
	ba = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a' and t[i] == 'b':
				ab.append(i + 1)
			else:
				ba.append(i + 1)
	ans = []
	for i in range(0, len(ab), 2):
		if i + 1 < len(ab):
			ans.append([ab[i], ab[i + 1]])
	for i in range(0, len(ba), 2):
		if i + 1 < len(ba):
			ans.append([ba[i], ba[i + 1]])
	if len(ab) % 2 and len(ba) % 2:
		ans.append([ba[len(ba) - 1], ba[len(ba) - 1]])
		ans.append([ab[len(ab) - 1], ba[len(ba) - 1]])
	print(len(ans))
	for i in ans:
		print(*i)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
from bisect import bisect_left
n = int(stdin.readline().strip())
a = list(stdin.readline().strip())
b = list(stdin.readline().strip())
a_b = []
b_a = []
for i in range(len(a)):
	if a[i] == 'a' and b[i] == 'b':
		a_b.append(i + 1)
	elif a[i] == 'b' and b[i] == 'a':
		b_a.append(i + 1)
op = 0
ans = []
if (len(a_b) + len(b_a)) % 2 == 0:
	while len(a_b) >= 2:
		first = a_b.pop()
		second = a_b.pop()
		ans.append([first, second])
		op += 1
	while len(b_a) >= 2:
		first = b_a.pop()
		second = b_a.pop()
		ans.append([first, second])
		op += 1
	if len(a_b) == 1 and len(b_a) == 1:
		op += 1
		first = a_b.pop()
		ans.append([first, first])
		op += 1
		second = b_a.pop()
		ans.append([first, second])
	print(op)
	for i in ans:
		print(*i)
else:
	print(-1)


n = int(input())
a = list(input())
b = list(input())
same = 0
ab = 0
ba = 0
abi = []
bai = []
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		ab += 1
		abi.append(i + 1)
	elif a[i] == 'b' and b[i] == 'a':
		ba += 1
		bai.append(i + 1)
k = ab // 2 + ba // 2
if ab % 2 + ba % 2 == 0:
	l = 1
	print(k)
elif ab % 2 + ba % 2 == 2:
	l = 2
	print(k + 2)
else:
	l = 0
	print(-1)
if l == 1:
	i = 0
	while i < len(abi):
		print(abi[i], abi[i + 1])
		i += 2
	i = 0
	while i < len(bai):
		print(bai[i], bai[i + 1])
		i += 2
elif l == 2:
	i = 0
	while i < len(abi) - 1:
		print(abi[i], abi[i + 1])
		i += 2
	i = 0
	while i < len(bai) - 1:
		print(bai[i], bai[i + 1])
		i += 2
	print(abi[-1], abi[-1])
	print(abi[-1], bai[-1])


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
s1 = ls()
s2 = ls()
ab = []
ba = []
for i in range(n):
	if s1[i] != s2[i]:
		if s1[i] == 'a':
			ab.append(i)
		else:
			ba.append(i)
f = len(ab)
s = len(ba)
if (f + s) % 2 == 1:
	print(-1)
elif f % 2 == 0:
	print(f // 2 + s // 2)
	for i in range(f // 2):
		print(ab[i] + 1, end=' ')
		print(ab[i + f // 2] + 1)
	for i in range(s // 2):
		print(ba[i] + 1, end=' ')
		print(ba[i + s // 2] + 1)
else:
	print(f // 2 + s // 2 + 2)
	for i in range(f // 2):
		print(ab[i] + 1, end=' ')
		print(ab[i + f // 2] + 1)
	for i in range(s // 2):
		print(ba[i] + 1, end=' ')
		print(ba[i + s // 2] + 1)
	print(ab[f - 1] + 1, end=' ')
	print(ab[f - 1] + 1)
	print(ab[f - 1] + 1, end=' ')
	print(ba[s - 1] + 1)


n = int(input())
s = str(input())
t = str(input())
count1 = 0
count2 = 0
array1 = []
array2 = []
noa = 0
nob = 0
for i in range(0, n):
	if s[i] == 'a':
		noa += 1
	if t[i] == 'a':
		noa += 1
	if s[i] == 'b':
		nob += 1
	if t[i] == 'b':
		nob += 1
	if s[i] == 'a' and t[i] == 'b':
		count1 += 1
		array1.append(i)
	elif s[i] == 'b' and t[i] == 'a':
		count2 += 1
		array2.append(i)
if noa % 2 != 0 or nob % 2 != 0:
	print(-1)
else:
	ans = 0
	remainder = 0
	ans += count1 // 2
	flag = 0
	xi = []
	for i in range(0, len(array1), 2):
		if i != len(array1) - 1:
			xi.append((array1[i] + 1, array1[i + 1] + 1))
		else:
			flag = 1
	remainder += count1 % 2
	ans += count2 // 2
	remainder += count2 % 2
	for i in range(0, len(array2), 2):
		if i != len(array2) - 1:
			xi.append((array2[i] + 1, array2[i + 1] + 1))
	ans += remainder
	if remainder == 1:
		print(-1)
	else:
		print(ans)
		for i in xi:
			print(*i)
		if flag == 1:
			print(array2[-1] + 1, array2[-1] + 1)
			print(array1[-1] + 1, array2[-1] + 1)


n = int(input())
x = input()
y = input()
a = 0
b = 0
for j in range(n):
	if x[j] == 'a':
		a += 1
	else:
		b += 1
	if y[j] == 'a':
		a += 1
	else:
		b += 1
if a % 2 == 0 and b % 2 == 0:
	c = []
	d = []
	e = []
	for j in range(n):
		if x[j] == 'a' and y[j] == 'b':
			c.append(j + 1)
		elif x[j] == 'b' and y[j] == 'a':
			d.append(j + 1)
	if len(c) % 2 == 0:
		j = 0
		while j < len(c) - 1:
			e.append([c[j], c[j + 1]])
			j += 2
		j = 0
		while j < len(d) - 1:
			e.append([d[j], d[j + 1]])
			j += 2
	else:
		p = c[0]
		j = 1
		while j < len(c) - 1:
			e.append([c[j], c[j + 1]])
			j += 2
		q = d[0]
		j = 1
		while j < len(d) - 1:
			e.append([d[j], d[j + 1]])
			j += 2
		e.append([p, p])
		e.append([p, q])
	print(len(e))
	for j in e:
		print(*j)
else:
	print(-1)


n = int(input())
s = input()
t = input()
result = 0
out = []
ab = ba = -1
for i in range(n):
	if s[i] == t[i]:
		continue
	if s[i] == 'a' and t[i] == 'b':
		if ab != -1:
			out.append((ab + 1, i + 1))
			result += 1
			ab = -1
		else:
			ab = i
	elif ba != -1:
		out.append((ba + 1, i + 1))
		result += 1
		ba = -1
	else:
		ba = i
if (ab == -1) != (ba == -1):
	print(-1)
elif ab == ba == -1:
	print(result)
	for (i, j) in out:
		print(i, j)
else:
	print(result + 2)
	for (i, j) in out:
		print(i, j)
	print(ab + 1, ab + 1)
	print(ab + 1, ba + 1)


n = int(input())
a = input()
b = input()
temp = []
d = {'a': [], 'b': []}
for i in range(len(a)):
	if a[i] != b[i]:
		d[a[i]].append(i + 1)
if (len(d['a']) + len(d['b'])) % 2 != 0:
	print(-1)
else:
	cnt = 0
	final = []
	if len(d['a']) > 1:
		for i in range(0, len(d['a']) - 1, 2):
			s = str(d['a'][i])
			s = s + ' ' + str(d['a'][i + 1])
			cnt = cnt + 1
			final.append(s)
	if len(d['b']) > 1:
		for i in range(0, len(d['b']) - 1, 2):
			s = str(d['b'][i])
			s = s + ' ' + str(d['b'][i + 1])
			final.append(s)
			cnt = cnt + 1
	if len(d['a']) % 2 == 1:
		s1 = str(d['a'][len(d['a']) - 1]) + ' ' + str(d['a'][len(d['a']) - 1])
		s2 = str(d['a'][len(d['a']) - 1]) + ' ' + str(d['b'][len(d['b']) - 1])
		final.append(s1)
		final.append(s2)
		cnt = cnt + 2
	print(cnt)
	for i in final:
		print(i)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b):
	return abs(a[0] - b[0]) + abs(b[1] - a[1])

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def eld(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def fac(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans
n = int(input())
s1 = [i for i in input()]
s2 = [i for i in input()]
ab = []
ba = []
ans = []
a1 = s1.count('a')
a2 = s2.count('a')
b1 = s1.count('b')
b2 = s2.count('b')
if (a1 + a2) % 2 or (b1 + b2) % 2:
	print(-1)
	exit(0)
for i in range(n):
	if s1[i] + s2[i] == 'ab':
		ab.append(i)
	elif s1[i] + s2[i] == 'ba':
		ba.append(i)
j = 0
while j < len(ab) - 1:
	ans.append([ab[j] + 1, ab[j + 1] + 1])
	(s1[ab[j]], s2[ab[j + 1]]) = (s2[ab[j + 1]], s1[ab[j]])
	j += 2
k = 0
while k < len(ba) - 1:
	ans.append([ba[k] + 1, ba[k + 1] + 1])
	(s1[ba[k]], s2[ba[k + 1]]) = (s2[ba[k + 1]], s1[ba[k]])
	k += 2
if j == len(ab):
	if k == len(ba):
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print(-1)
elif k == len(ba):
	if j == len(ab):
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print(-1)
else:
	ans.append([ab[j] + 1, ab[j] + 1])
	ans.append([ab[j] + 1, ba[k] + 1])
	print(len(ans))
	for i in ans:
		print(*i)


n = int(input())
s = input()
t = input()
s = [str(i) for i in s]
t = [str(i) for i in t]
ans = []
flag = 0
n = len(s)
for i in range(n):
	if s[i] != t[i]:
		for j in range(i + 1, n):
			if s[i] == s[j] and t[i] == t[j]:
				(s[j], t[i]) = (t[i], s[j])
				ans.insert(len(ans), j + 1)
				ans.insert(len(ans), i + 1)
				flag += 1
				break
	if s[i] != t[i]:
		for j in range(i + 1, n):
			if s[i] == t[j] and t[i] == s[j]:
				(s[j], t[j]) = (t[j], s[j])
				(s[j], t[i]) = (t[i], s[j])
				ans.insert(len(ans), j + 1)
				ans.insert(len(ans), j + 1)
				ans.insert(len(ans), i + 1)
				ans.insert(len(ans), j + 1)
				flag += 2
				break
	if s[i] != t[i]:
		flag = -1
		break
print(flag)
if flag != -1:
	for i in range(0, len(ans) - 1, 2):
		print(ans[i], ans[i + 1])


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		a = list(rs())
		b = list(rs())
		da = Counter(a)
		db = Counter(b)
		if (da['a'] + db['a']) % 2 or (da['b'] + db['b']) % 2:
			print(-1)
		else:
			ans = 0
			z = []
			for i in range(n):
				if a[i] != b[i]:
					c = 0
					for j in range(i + 1, n):
						if a[i] == a[j] and b[i] == b[j]:
							ans += 1
							z.append([i + 1, j + 1])
							c = 1
							(a[i], b[j]) = (b[j], a[i])
							break
					if c == 0:
						for j in range(i + 1, n):
							if a[i] == b[j] and b[j] != a[j]:
								ans += 2
								z.append([i + 1, i + 1])
								z.append([j + 1, i + 1])
								(a[i], b[i]) = (b[i], a[i])
								(b[i], a[j]) = (a[i], b[j])
								break
			print(ans)
			for i in z:
				print(*i)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def answer(n, A, B):
	count = 0
	d = {}
	for i in range(n):
		if A[i] == 'a':
			count += 1
		if B[i] == 'a':
			count += 1
		if (A[i], B[i]) in d:
			d[A[i], B[i]].append(i + 1)
		else:
			d[A[i], B[i]] = [i + 1]
	if count % 2 != 0:
		return -1
	ans = []
	k1 = -1
	k2 = -1
	if ('a', 'b') in d:
		v = d['a', 'b']
		for i in range(0, len(v) - len(v) % 2, 2):
			ans.append([v[i], v[i + 1]])
		if len(v) % 2 != 0:
			k1 = v[-1]
	if ('b', 'a') in d:
		v = d['b', 'a']
		for i in range(0, len(v) - len(v) % 2, 2):
			ans.append([v[i], v[i + 1]])
		if len(v) % 2 != 0:
			k2 = v[-1]
	if k1 != -1 and k2 != -1:
		ans.append([k1, k1])
		ans.append([k1, k2])
	return ans
n = int(input())
s = input()
t = input()
y = answer(n, s, t)
if y == -1:
	print(-1)
else:
	print(len(y))
	for i in range(len(y)):
		print(*y[i])


n = int(input())
s = input().rstrip()
t = input().rstrip()
tobe_a = []
tobe_b = []
for (i, (sch, tch)) in enumerate(zip(s, t)):
	if sch == 'b' and tch == 'a':
		tobe_a.append(i + 1)
	elif sch == 'a' and tch == 'b':
		tobe_b.append(i + 1)
if (len(tobe_a) + len(tobe_b)) % 2 != 0:
	print(-1)
	return
ans = []
for (a1, a2) in zip(tobe_a[::2], tobe_a[1::2]):
	ans.append((a1, a2))
for (b1, b2) in zip(tobe_b[::2], tobe_b[1::2]):
	ans.append((b1, b2))
if len(tobe_a) % 2 == 1:
	ans.append((tobe_a[-1], tobe_a[-1]))
	ans.append((tobe_a[-1], tobe_b[-1]))
print(len(ans))
for (a, b) in ans:
	print(a, b)


n = int(input())
s = input()
s1 = []
for i in s:
	s1.append(i)
t = input()
t1 = []
for i in t:
	t1.append(i)
sa = s.count('a')
ta = t.count('a')
if (sa + ta) % 2 != 0 or (2 * n - sa - ta) % 2 != 0:
	print(-1)
else:
	ans = []
	y = []
	i = 0
	k = 0
	while i < n:
		if t1[i] != s1[i]:
			y.append([s1[i], t1[i], k + 1])
		i += 1
		k += 1
	y = sorted(y)
	if len(y) == 0:
		print(0)
	else:
		i = 1
		while i < n:
			if y[i][0] != y[i - 1][0]:
				break
			i += 1
		if i % 2 == 0:
			i = 1
			while i < len(y):
				ans.append([y[i - 1][2], y[i][2]])
				i += 2
			print(len(ans))
			for i in ans:
				print(i[0], i[1])
		else:
			i = 2
			while i < len(y) - 1:
				ans.append([y[i - 1][2], y[i][2]])
				i += 2
			ans.append([y[0][2], y[0][2]])
			ans.append([y[0][2], y[-1][2]])
			print(len(ans))
			for i in ans:
				print(i[0], i[1])


n = int(input())
s = input()
t = input()
op = 0
b = 0
B = []
a = 0
A = []
OP = []
if (s.count('a') + t.count('a')) % 2 * ((s.count('b') + t.count('b')) % 2):
	print(-1)
else:
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'b':
				b += 1
				B.append(i + 1)
				if b == 2:
					op += 1
					OP += B
					B = []
					b = 0
			else:
				a += 1
				A.append(i + 1)
				if a == 2:
					op += 1
					OP += A
					A = []
					a = 0
	op += a + b
	if a * b:
		OP += [B[0], B[0]]
		OP += [B[0], A[0]]
	print(op)
	for i in range(op):
		print(OP[i * 2], OP[i * 2 + 1])


n = int(input())
a = list(input())
b = list(input())
aa = 0
bb = 0
c = []
d = []
for i in range(n):
	if a[i] != b[i]:
		if a[i] == 'a':
			aa += 1
			c.append(i + 1)
		else:
			bb += 1
			d.append(i + 1)
if aa % 2 != bb % 2:
	print(-1)
elif aa % 2 == 0:
	print(aa // 2 + bb // 2)
	i = 0
	while i < len(c) - 1:
		print(c[i], c[i + 1])
		i += 2
	i = 0
	while i < len(d) - 1:
		print(d[i], d[i + 1])
		i += 2
else:
	i = 0
	print(aa // 2 + bb // 2 + 2)
	while i < len(c) - 2:
		print(c[i], c[i + 1])
		i += 2
	i = 0
	while i < len(d) - 2:
		print(d[i], d[i + 1])
		i += 2
	print(c[-1], c[-1])
	print(c[-1], d[-1])


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = input()
b = input()
one = []
two = []
for i in range(n):
	if a[i] == b[i]:
		pass
	elif a[i] == 'a':
		one.append(i + 1)
	else:
		two.append(i + 1)
if (len(one) + len(two)) % 2 == 1:
	print(-1)
else:
	k = len(one) + len(two)
	steps = []
	for i in range(0, len(one), 2):
		if i + 1 < len(one):
			steps.append((one[i], one[i + 1]))
	for i in range(0, len(two), 2):
		if i + 1 < len(two):
			steps.append((two[i], two[i + 1]))
	if len(one) % 2 == 1:
		steps.append((one[-1], one[-1]))
		steps.append((one[-1], two[-1]))
	print(len(steps))
	for i in steps:
		print(*i)


n = int(input())
s = input()
t = input()
s_a = []
s_b = []
diffs = 0
for i in range(n):
	if s[i] != t[i]:
		diffs += 1
		if s[i] == 'a':
			s_a.append(i + 1)
		else:
			s_b.append(i + 1)
if diffs % 2 != 0:
	print('-1')
else:
	if len(s_a) % 2 == 0:
		print(len(s_a) // 2 + len(s_b) // 2)
	else:
		print(len(s_a) // 2 + len(s_b) // 2 + 2)
	for i in range(0, len(s_a) - 1, 2):
		print(str(s_a[i]) + ' ' + str(s_a[i + 1]))
	for i in range(0, len(s_b) - 1, 2):
		print(str(s_b[i]) + ' ' + str(s_b[i + 1]))
	if len(s_a) % 2 != 0:
		print(str(s_a[-1]) + ' ' + str(s_a[-1]))
		print(str(s_a[-1]) + ' ' + str(s_b[-1]))


n = int(input())
s1 = input()
s2 = input()
cnt1 = 0
cnt2 = 0
swap = []
a = []
b = []
c = s1.count('a') + s2.count('a')
cc = s1.count('b') + s2.count('b')
if c % 2 != 0 or cc % 2 != 0:
	print(-1)
	exit()
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		cnt1 += 1
		a.append(i + 1)
	elif s1[i] == 'b' and s2[i] == 'a':
		cnt2 += 1
		b.append(i + 1)
if cnt1 % 2 == 0:
	ans = cnt1 // 2 + cnt2 // 2
	print(ans)
	i = 0
	while i < len(a) - 1:
		print(a[i], a[i + 1])
		i += 2
	i = 0
	while i < len(b) - 1:
		print(b[i], b[i + 1])
		i = i + 2
else:
	ans = cnt1 // 2 + cnt2 // 2 + 2
	print(ans)
	i = 0
	while i < len(a) - 1:
		print(a[i], a[i + 1])
		i += 2
	i = 0
	while i < len(b) - 1:
		print(b[i], b[i + 1])
		i = i + 2
	x = a.pop()
	y = b.pop()
	print(x, x)
	print(x, y)


n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(0, n):
	if s[i] != t[i]:
		if s[i] == 'a':
			ab.append(i)
		else:
			ba.append(i)
if (len(ab) + len(ba)) % 2 != 0:
	print(-1)
	exit()
moves = []
for i in range(int(len(ab) / 2)):
	moves.append((ab[i * 2], ab[i * 2 + 1]))
for i in range(int(len(ba) / 2)):
	moves.append((ba[i * 2], ba[i * 2 + 1]))
if len(ab) % 2 == 1:
	last_ab = ab[len(ab) - 1]
	last_ba = ba[len(ba) - 1]
	moves.append((last_ab, last_ab))
	moves.append((last_ab, last_ba))
print(len(moves))
for m in moves:
	print(m[0] + 1, m[1] + 1)


N = int(input())
s = input()
t = input()
ans = []
a = -1
b = -1
swaps = 0
for i in range(N):
	if s[i] == 'a' and t[i] == 'b':
		if a == -1:
			a = i
		else:
			ans.append((a, i))
			swaps += 1
			a = -1
	elif s[i] == 'b' and t[i] == 'a':
		if b == -1:
			b = i
		else:
			ans.append((b, i))
			swaps += 1
			b = -1
if a == -1 and b != -1 or (b == -1 and a != -1):
	print('-1')
else:
	if a != -1:
		swaps += 2
		ans.append((a, a))
		ans.append((a, b))
	print(swaps)
	for (u, v) in ans:
		print(u + 1, v + 1)


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	n = int(input())
	s = input()
	t = input()
	data = {('a', 'b'): set(), ('b', 'a'): set()}
	for i in range(n):
		if s[i] != t[i]:
			data[s[i], t[i]].add(i + 1)
	ans = []
	s = len(data['a', 'b'])
	while s != 0:
		if s >= 2:
			(first, second) = (data['a', 'b'].pop(), data['a', 'b'].pop())
			s -= 2
			ans.append((first, second))
		else:
			break
	s = len(data['b', 'a'])
	while s != 0:
		if s >= 2:
			(first, second) = (data['b', 'a'].pop(), data['b', 'a'].pop())
			s -= 2
			ans.append((first, second))
		else:
			break
	if data['b', 'a'] and data['a', 'b']:
		step = data['b', 'a'].pop()
		ans.append((step, step))
		data['a', 'b'].add(step)
		(first, second) = (data['a', 'b'].pop(), data['a', 'b'].pop())
		ans.append((first, second))
		print(len(ans))
		for k in ans:
			print(*k)
		return
	if data['b', 'a'] and (not data['a', 'b']) or (not data['b', 'a'] and data['a', 'b']):
		print(-1)
		return
	print(len(ans))
	for k in ans:
		print(*k)
	return
main()


n = int(input())
s = list(input())
t = list(input())
i = 0
cnt = 0
ind = []
grp1 = []
grp2 = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		grp1.append(i)
	elif s[i] == 'b' and t[i] == 'a':
		grp2.append(i)
cnt = 0
ind = []
while len(grp1) > 1:
	cnt += 1
	ind.append(grp1.pop() + 1)
	ind.append(grp1.pop() + 1)
while len(grp2) > 1:
	cnt += 1
	ind.append(grp2.pop() + 1)
	ind.append(grp2.pop() + 1)
if len(grp1) != 0 and len(grp2) != 0:
	cnt += 2
	p1 = grp1.pop()
	p2 = grp2.pop()
	ind.append(p1 + 1)
	ind.append(p1 + 1)
	ind.append(p1 + 1)
	ind.append(p2 + 1)
	print(cnt)
	for i in range(0, len(ind), 2):
		print(ind[i], ind[i + 1])
elif not grp1 and (not grp2):
	print(cnt)
	for i in range(0, len(ind), 2):
		print(ind[i], ind[i + 1])
else:
	print(-1)


n = int(input())
s = list(input())
t = list(input())
s_rem = [[], []]
t_rem = [[], []]
for i in range(n - 1, -1, -1):
	if s[i] != t[i]:
		s_is_b = s[i] == 'b'
		s_rem[s_is_b].append(i)
		t_rem[s_is_b ^ 1].append(i)
ans = []
for c in range(2):
	while s_rem[c]:
		i = s_rem[c].pop()
		if s[i] == t[i]:
			continue
		if s_rem[c]:
			k = s_rem[c].pop()
			ans.append((k, i))
			(s[k], t[i]) = (t[i], s[k])
		elif s_rem[c ^ 1]:
			ans.append((i, i))
			(s[i], t[i]) = (t[i], s[i])
			k = s_rem[c ^ 1].pop()
			ans.append((k, i))
			(s[k], t[i]) = (t[k], s[k])
		else:
			break
if s == t:
	print(len(ans))
	for p in ans:
		print(p[0] + 1, p[1] + 1)
else:
	print(-1)


n = int(input())
s = input()
t = input()
i = 1
count = 0
arr1 = []
arr2 = []
while i < n + 1:
	if s[i - 1] != t[i - 1]:
		if s[i - 1] == 'a':
			arr1.append(i)
		else:
			arr2.append(i)
	i += 1
x = len(arr1)
y = len(arr2)
if (x + y) % 2 == 1:
	print(-1)
else:
	print(x // 2 + y // 2 + 2 * (x % 2))
	for i in range(0, x - 1, 2):
		print(str(arr1[i]) + ' ' + str(arr1[i + 1]))
	for i in range(0, y - 1, 2):
		print(str(arr2[i]) + ' ' + str(arr2[i + 1]))
	if x % 2 == 1:
		print(str(arr1[-1]) + ' ' + str(arr1[-1]))
		print(str(arr1[-1]) + ' ' + str(arr2[-1]))


n = int(input())
s = input()
t = input()
c = []
d = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		c.append(i + 1)
	if s[i] == 'b' and t[i] == 'a':
		d.append(i + 1)
k = len(c)
h = len(d)
if (h + k) % 2:
	print(-1)
elif k % 2:
	print((h + k) // 2 + 1)
	i = 0
	while i < k - 1:
		print(c[i], c[i + 1])
		i += 2
	j = 0
	while j < h - 1:
		print(d[j], d[j + 1])
		j += 2
	print(d[h - 1], d[h - 1])
	print(d[h - 1], c[k - 1])
else:
	print((h + k) // 2)
	i = 0
	while i < k:
		print(c[i], c[i + 1])
		i += 2
	j = 0
	while j < h:
		print(d[j], d[j + 1])
		j += 2


n = int(input())
a = list(input())
b = list(input())
s = []
h = []
for i in range(0, n):
	if a[i] != b[i]:
		if a[i] == 'a':
			s.append(i + 1)
		if a[i] == 'b':
			h.append(i + 1)
c = len(s)
d = len(h)
if c % 2 == 0 and d % 2 == 0:
	print((c + d) // 2)
	for i in range(c // 2):
		print(s[i], s[c - i - 1])
	for i in range(d // 2):
		print(h[i], h[d - i - 1])
elif c % 2 != 0 and d % 2 != 0:
	print(c // 2 + d // 2 + 2)
	for i in range(c // 2):
		print(s[i], s[c - i - 1])
	for i in range(d // 2):
		print(h[i], h[d - i - 1])
	k = c // 2
	f = d // 2
	print(h[f], h[f])
	print(s[k], h[f])
else:
	print(-1)


import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
n = int(input())
a1 = input()
a2 = input()
(c, cc) = (0, 0)
c1 = []
c2 = []
for i in range(n):
	if a1[i] != a2[i]:
		if a1[i] == 'a':
			c += 1
			c1.append(i)
		else:
			cc += 1
			c2.append(i)
if (c + cc) % 2 != 0:
	print(-1)
else:
	le1 = len(c1)
	le2 = len(c2)
	if le2 % 2 == 0 or le2 == 0:
		print((le1 + le2) // 2)
		for i in range(le1 // 2):
			print(c1.pop() + 1, c1.pop() + 1)
		for i in range(le2 // 2):
			print(c2.pop() + 1, c2.pop() + 1)
	else:
		print((le1 + le2) // 2 + 1)
		for i in range(le1 // 2):
			print(c1.pop() + 1, c1.pop() + 1)
		for i in range(le2 // 2):
			print(c2.pop() + 1, c2.pop() + 1)
		an1 = c1.pop()
		an2 = c2.pop()
		print(an1 + 1, an1 + 1)
		print(an1 + 1, an2 + 1)


n = int(input())
s = input()
t = input()
ab = []
ba = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab.append(i + 1)
	elif s[i] == 'b' and t[i] == 'a':
		ba.append(i + 1)
if (len(ab) + len(ba)) % 2:
	print(-1)
else:
	operator = []
	if len(ab) % 2:
		operator += [[ab[-1], ab[-1]], [ab[-1], ba[-1]]]
		ab.pop()
		ba.pop()
	for i in range(0, len(ab), 2):
		operator.append([ab[i], ab[i + 1]])
	for i in range(0, len(ba), 2):
		operator.append([ba[i], ba[i + 1]])
	print(len(operator))
	for (a, b) in operator:
		print(a, b)


n = int(input())
s1 = list(input())
s2 = list(input())
ans = list()
for i in range(0, n):
	if s1[i] == s2[i]:
		s1[i] = 0
		s2[i] = 0
i = 0
j = i + 1
c = 0
while i < n:
	if j > n - 1:
		i = i + 1
		j = i + 1
		continue
	f = 0
	if s1[i] == 0:
		i = i + 1
		j = i + 1
		continue
	if s2[j] == 0:
		j = j + 1
		continue
	if s1[i] != s2[j]:
		c = c + 1
		ans.append((i + 1, j + 1))
		s1[i] = 0
		s2[i] = 0
		s1[j] = 0
		s2[j] = 0
		i = i + 1
		j = i + 1
		f = 1
	if f == 0:
		j = j + 1
l1 = list()
f = 1
k = 0
for i in range(0, n):
	if s1[i] != 0:
		l1.append(i)
		k = k + 1
if k % 2 != 0:
	print(-1)
	f = 0
else:
	for i in range(0, k, 2):
		ans.append((l1[i] + 1, l1[i] + 1))
		ans.append((l1[i + 1] + 1, l1[i] + 1))
if f == 1:
	print(len(ans))
	for (i, j) in ans:
		print(i, j)


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	k = 0
	n = fi()
	s = si()
	p = si()
	d = [[], []]
	ans = []
	for i in range(n):
		if s[i] != p[i]:
			d[bo(s[i])].append(i + 1)
			k += 1
	if k % 2:
		print(-1)
		continue
	for u in range(2):
		while len(d[u]) > 1:
			a = d[u][-1]
			b = d[u][-2]
			ans.append([a, b])
			d[u].pop()
			d[u].pop()
	if len(d[0]) + len(d[1]) == 2:
		ans.append([d[0][-1], d[0][-1]])
		ans.append([d[0][-1], d[1][-1]])
	print(len(ans))
	for i in ans:
		print(*i)


def swap(s, t, i, j):
	(s[i], t[j]) = (t[j], s[i])
n = int(input())
s = []
t = []
s[:0] = input()
t[:0] = input()
k = 0
a = []
b = []
ans = []
works = True
for i in range(n):
	if s[i] != t[i]:
		a.append(False)
		works = not works
	else:
		a.append(True)
for i in range(n):
	if not a[i]:
		done = False
		for j in range(i + 1, n):
			if not a[j] and s[i] != t[j]:
				swap(s, t, i, j)
				k += 1
				ans.append(i)
				ans.append(j)
				a[i] = True
				a[j] = True
				break
for i in range(n):
	if not a[i]:
		swap(s, t, i, i)
		ans.append(i)
		ans.append(i)
		ind = len(a) - a[::-1].index(False) - 1
		swap(s, t, i, ind)
		ans.append(i)
		ans.append(ind)
		a[i] = True
		a[ind] = True
		k += 2
if works:
	print(k)
	for i in range(k):
		print(ans[2 * i] + 1, end=' ')
		print(ans[2 * i + 1] + 1)
else:
	print(-1)


n = int(input())
s = input()
t = input()
ab = 0
ba = 0
ab_index = []
ba_index = []
swap_index = []
for i in range(n):
	if s[i] == 'a' and t[i] == 'b':
		ab_index.append(i)
	elif s[i] == 'b' and t[i] == 'a':
		ba_index.append(i)
ab = len(ab_index)
ba = len(ba_index)
if (ab + ba) % 2:
	print(-1)
else:
	ans = 0
	ans += ab // 2
	ans += ba // 2
	if ab % 2:
		ans += 2
	for i in range(0, ab, 2):
		if i == ab - 1:
			break
		swap_index.append([ab_index[i], ab_index[i + 1]])
	for i in range(0, ba, 2):
		if i == ba - 1:
			break
		swap_index.append([ba_index[i], ba_index[i + 1]])
	if ab % 2:
		swap_index.append([ab_index[-1], ab_index[-1]])
		swap_index.append([ab_index[-1], ba_index[-1]])
	print(ans)
	for i in swap_index:
		print(i[0] + 1, i[1] + 1)


n = int(input())
s = input()
s = list(s)
t = input()
t = list(t)
A = []
B = []
Ans = []
for i in range(n):
	if s[i] != t[i]:
		if t[i] == 'a':
			A.append(i + 1)
		else:
			B.append(i + 1)
if len(A) % 2 != len(B) % 2:
	print('-1')
else:
	print(len(A) // 2 + len(B) // 2 + (len(A) & 1) + (len(B) & 1))
	j = 0
	for i in range(0, len(A) - 1, 2):
		print(A[j], end=' ')
		print(A[j + 1])
		j += 2
	p = 0
	for i in range(0, len(B) - 1, 2):
		print(B[p], end=' ')
		print(B[p + 1])
		p += 2
	if len(A) % 2:
		print(A[j], A[j])
		print(A[j], B[p])


n = int(input())
s1 = list(input())
s2 = list(input())
a = 0
b = 0
for i in s1 + s2:
	if i == 'a':
		a += 1
	else:
		b += 1
if a % 2 or b % 2:
	print(-1)
	exit()
ab = set()
ba = set()
for i in range(n):
	if s1[i] == 'a' and s2[i] == 'b':
		ab.add(i)
	elif s2[i] == 'a' and s1[i] == 'b':
		ba.add(i)
r = []
i = 0
while i < n:
	if s1[i] == 'a' and s2[i] == 'b':
		for j in ab:
			if j != i:
				break
		else:
			r.append([i + 1, i + 1])
			ab.remove(i)
			ba.add(i)
			s1[i] = 'b'
			s2[i] = 'a'
			continue
		ab.remove(i)
		ab.remove(j)
		s1[i] = 'b'
		s2[j] = 'a'
		r.append([i + 1, j + 1])
	elif s2[i] == 'a' and s1[i] == 'b':
		for j in ba:
			if j != i:
				break
		else:
			r.append([i + 1, i + 1])
			ba.remove(i)
			ab.add(i)
			s1[i] = 'a'
			s2[i] = 'b'
			continue
		ba.remove(i)
		ba.remove(j)
		s1[i] = 'a'
		s2[j] = 'b'
		r.append([i + 1, j + 1])
	i += 1
print(len(r))
for i in r:
	print(*i)


n = int(input())
ch1 = input()
ch2 = input()
k = 0
(c1, c2) = (0, 0)
d1 = []
d2 = []
s = []
for i in range(n):
	if ch1[i] == 'a' and ch2[i] == 'b':
		c1 += 1
		d1.append(i)
	elif ch1[i] == 'b' and ch2[i] == 'a':
		c2 += 1
		d2.append(i)
	if c1 >= 2:
		s.append([d1[0] + 1, d1[1] + 1])
		d1 = []
		c1 = 0
		k += 1
	if c2 >= 2:
		s.append([d2[0] + 1, d2[1] + 1])
		c2 = 0
		d2 = []
		k += 1
if c1 != c2:
	print(-1)
else:
	if c1 == 1:
		k += 2
		s.append([d1[0] + 1, d1[0] + 1])
		s.append([d1[0] + 1, d2[0] + 1])
	print(k)
	for i in range(len(s)):
		print(*s[i], sep=' ')


n = int(input())
(s1, s2) = (input(), input())
(arr1, arr2) = ([0] * n, [0] * n)
for i in range(n):
	arr1[i] = 0 if s1[i] == 'a' else 1
	arr2[i] = 0 if s2[i] == 'a' else 1
if (sum(arr1) + sum(arr2)) % 2 != 0:
	print(-1)
else:
	problem0 = []
	problem1 = []
	ans = []
	for i in range(n):
		if arr1[i] == 0 and arr2[i] == 1:
			problem0.append(i)
		if arr1[i] == 1 and arr2[i] == 0:
			problem1.append(i)
	for i in range(1, len(problem0), 2):
		ans.append([problem0[i - 1], problem0[i]])
	for i in range(1, len(problem1), 2):
		ans.append([problem1[i - 1], problem1[i]])
	(n1, n2) = (len(problem0), len(problem1))
	if n1 % 2 != 0:
		ans.append([problem0[n1 - 1], problem0[n1 - 1]])
		ans.append([problem0[n1 - 1], problem1[n2 - 1]])
	print(len(ans))
	for row in ans:
		print(' '.join([str(elem + 1) for elem in row]))


n = int(input())
s1 = str(input())
s2 = str(input())
ab = []
ba = []
ans = 0
anss = []
l = []
for i in range(n):
	if s1[i] != s2[i]:
		l.append(i)
if len(l) == 0:
	print(0)
else:
	for i in range(n):
		if s1[i] == 'a' and s2[i] == 'b':
			ab.append(i)
		elif s1[i] == 'b' and s2[i] == 'a':
			ba.append(i)
	ans += len(ab) // 2 + len(ba) // 2
	c = len(ab)
	d = len(ba)
	for i in range(0, len(ab), 2):
		if i != c - 1:
			anss.append([ab[i] + 1, ab[i + 1] + 1])
	for i in range(0, len(ba), 2):
		if i != d - 1:
			anss.append([ba[i] + 1, ba[i + 1] + 1])
	if c % 2 == 0 and d % 2 == 0:
		print(ans)
		for i in anss:
			print(*i)
	elif c % 2 != 0 and d % 2 != 0:
		ans += 2
		anss.append([ab[-1] + 1, ab[-1] + 1])
		anss.append([ab[-1] + 1, ba[-1] + 1])
		print(ans)
		for i in anss:
			print(*i)
	else:
		print(-1)


def run():
	n = eval(input())
	s1 = input()
	s2 = input()
	num_diffs = 0
	one_ind = []
	two_ind = []
	for i in range(n):
		if s1[i] != s2[i]:
			if s1[i] == 'a':
				one_ind.append(i)
			else:
				two_ind.append(i)
	if (len(one_ind) + len(two_ind)) % 2 == 1:
		print(-1)
		return
	result = []
	c = 0
	last_one = None
	last_two = None
	i = 0
	while i < len(one_ind):
		if i == len(one_ind) - 1:
			break
		result.append(str(one_ind[i] + 1) + ' ' + str(one_ind[i + 1] + 1))
		i += 2
	if i == len(one_ind) - 1:
		one_ind = one_ind[i:]
	else:
		one_ind = []
	j = 0
	while j < len(two_ind):
		if j == len(two_ind) - 1:
			break
		result.append(str(two_ind[j] + 1) + ' ' + str(two_ind[j + 1] + 1))
		j += 2
	if j == len(two_ind) - 1:
		two_ind = two_ind[j:]
	else:
		two_ind = []
	if len(two_ind) > 0:
		result.append(str(one_ind[-1] + 1) + ' ' + str(one_ind[-1] + 1))
		result.append(str(one_ind[-1] + 1) + ' ' + str(two_ind[-1] + 1))
	c = len(result)
	print(c)
	for i in result:
		print(i)
run()


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = si()
	b = si()
	xa = []
	xb = []
	for i in range(n):
		if a[i] != b[i]:
			if a[i] == 'a':
				xb.append(i + 1)
			else:
				xa.append(i + 1)
	n1 = len(xa)
	n2 = len(xb)
	if (n1 + n2) % 2:
		print('-1')
		exit(0)
	ans = []
	for i in range(0, n1 - 1, 2):
		ans.append([xa[i], xa[i + 1]])
	for i in range(0, n2 - 1, 2):
		ans.append([xb[i], xb[i + 1]])
	if n1 % 2 and n2 % 2:
		ans.append([xa[n1 - 1], xa[n1 - 1]])
		ans.append([xa[n1 - 1], xb[n2 - 1]])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])
solve()


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	a = insr()
	b = insr()
	aIndex = list()
	bIndex = list()
	if (a.count('a') + b.count('a')) % 2 != 0:
		print(-1)
	else:
		for i in range(n):
			if a[i] != b[i]:
				if a[i] == 'a':
					aIndex.append(i + 1)
				else:
					bIndex.append(i + 1)
		steps = len(aIndex) // 2 + len(bIndex) // 2 + len(aIndex) % 2 + len(bIndex) % 2
		print(steps)
		for i in range(0, len(aIndex) - 1, 2):
			print(aIndex[i], aIndex[i + 1])
		for i in range(0, len(bIndex) - 1, 2):
			print(bIndex[i], bIndex[i + 1])
		if len(aIndex) % 2 == 1:
			print(aIndex[-1], aIndex[-1])
			print(aIndex[-1], bIndex[-1])


n = int(input())
a = input()
b = input()
c = []
d = []
for i in range(n):
	if a[i] == 'a' and b[i] == 'b':
		c.append(i)
	elif a[i] == 'b' and b[i] == 'a':
		d.append(i)
if len(d) % 2 == 1 and len(c) % 2 == 1:
	print(2 + len(d) // 2 + len(c) // 2)
	print(c[-1] + 1, c[-1] + 1)
	print(c[-1] + 1, d[-1] + 1)
	for i in range(1, len(c), 2):
		print(c[i - 1] + 1, c[i] + 1)
	for i in range(1, len(d), 2):
		print(d[i - 1] + 1, d[i] + 1)
elif len(d) % 2 == 0 and len(c) % 2 == 0:
	print(len(c) // 2 + len(d) // 2)
	for i in range(1, len(c), 2):
		print(c[i - 1] + 1, c[i] + 1)
	for i in range(1, len(d), 2):
		print(d[i - 1] + 1, d[i] + 1)
else:
	print(-1)
	exit(0)


n = int(input())
s = input()
t = input()
s = list(s)
t = list(t)
sa = s.count('a')
ta = t.count('a')
if (sa + ta) % 2 != 0:
	print(-1)
else:
	sequence = []
	mismatchedIndexes = []
	for i in range(n):
		if s[i] != t[i]:
			mismatchedIndexes.append(i)
	swapsForBalance = sa - (sa + ta) // 2
	if swapsForBalance > 0:
		l = 0
		r = len(mismatchedIndexes) - 1
		while swapsForBalance > 0:
			while True:
				leftIdx = mismatchedIndexes[l]
				if s[leftIdx] == 'a':
					break
				l += 1
			while True:
				rightIdx = mismatchedIndexes[r]
				if t[rightIdx] == 'b':
					break
				r -= 1
			sequence.append([leftIdx + 1, rightIdx + 1])
			s[leftIdx] = 'b'
			t[rightIdx] = 'a'
			swapsForBalance -= 1
			l += 1
			r -= 1
	if swapsForBalance < 0:
		l = 0
		r = len(mismatchedIndexes) - 1
		while swapsForBalance < 0:
			while True:
				leftIdx = mismatchedIndexes[l]
				if s[leftIdx] == 'b':
					break
				l += 1
			while True:
				rightIdx = mismatchedIndexes[r]
				if t[rightIdx] == 'a':
					break
				r -= 1
			sequence.append([leftIdx + 1, rightIdx + 1])
			s[leftIdx] = 'a'
			t[rightIdx] = 'b'
			swapsForBalance += 1
			l += 1
			r -= 1
	mismatchedAsinS = []
	mismatchedBsinS = []
	for i in range(n):
		if s[i] != t[i]:
			if s[i] == 'a':
				mismatchedAsinS.append(i)
			else:
				mismatchedBsinS.append(i)
	for bIdxInT in range(n):
		if t[bIdxInT] == 'b':
			break
	aIdx = 0
	bIdx = 0
	while aIdx < len(mismatchedAsinS) or bIdx < len(mismatchedBsinS):
		if aIdx + 1 < len(mismatchedAsinS):
			sequence.append([mismatchedAsinS[aIdx] + 1, mismatchedAsinS[aIdx + 1] + 1])
			aIdx += 2
		if bIdx + 1 < len(mismatchedBsinS):
			sequence.append([mismatchedBsinS[bIdx] + 1, mismatchedBsinS[bIdx + 1] + 1])
			bIdx += 2
		if aIdx == len(mismatchedAsinS) - 1 and bIdx == len(mismatchedBsinS) - 1:
			sequence.append([mismatchedAsinS[aIdx] + 1, bIdxInT + 1])
			sequence.append([mismatchedBsinS[bIdx] + 1, bIdxInT + 1])
			aIdx += 1
			bIdx += 1
	print(len(sequence))

	def multiLineArrayOfArraysPrint(arr):
		print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
	multiLineArrayOfArraysPrint(sequence)