Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the Internet, he learned about the Hamming distance between two strings S and T of the same length, which is defined as the number of positions in which S and T have different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.

Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string S, so that the Hamming distance between a new string S and string T would be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.

Help him do this!


-----Input-----

The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T.

The second line contains string S.

The third line contains string T.

Each of the lines only contains lowercase Latin letters.


-----Output-----

In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S.

In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or print "-1 -1", if it is not necessary to swap characters.

If there are multiple possible answers, print any of them.


-----Examples-----
Input
9
pergament
permanent

Output
1
4 6

Input
6
wookie
cookie

Output
1
-1 -1

Input
4
petr
egor

Output
2
1 2

Input
6
double
bundle

Output
2
4 1



-----Note-----

In the second test it is acceptable to print i = 2, j = 3.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms


Solutions:
n = int(input())
s = input()
t = input()
(dic, diff) = ({}, [])
(res, res1, res2) = (0, -1, -1)
for i in range(n):
	if s[i] != t[i]:
		res += 1
		diff.append(i)
		dic[t[i]] = i
(swap1, swap2) = (False, False)
for i in diff:
	if s[i] in dic:
		swap1 = True
		res1 = i + 1
		j = dic[s[i]]
		res2 = j + 1
		if s[j] == t[i]:
			swap2 = True
			break
print(res - (2 if swap2 else 1 if swap1 else 0))
print(res1, res2)


xxx = 0
a1 = []
a2 = []
a = int(input())
x = input()
y = input()
of1 = []
of2 = []
a1 = {}
a2 = {}
for i in 'abcdefghijklmnopqrstuvwxyz':
	a1[i] = []
	a2[i] = []
for i in range(a):
	if x[i] != y[i]:
		a1[x[i]].append(i + 1)
		a2[y[i]].append(i + 1)
	else:
		xxx += 1
for i in 'abcdefghijklmnopqrstuvwxyz':
	for j in 'abcdefghijklmnopqrstuvwxyz':
		if j != i:
			aa1 = a1[i]
			bb1 = a2[j]
			cc1 = a1[j]
			dd1 = a2[i]
			ee = set(aa1).intersection(bb1)
			ff = set(cc1).intersection(dd1)
			if ee != set() and ff != set():
				print(a - xxx - 2)
				print(list(ee)[0], list(ff)[0])
				quit()
for i in 'abcdefghijklmnopqrstuvwxyz':
	for j in 'abcdefghijklmnopqrstuvwxyz':
		if j != i:
			aa1 = a1[i]
			bb1 = a2[j]
			cc1 = a1[j]
			dd1 = a2[i]
			ee = set(aa1).intersection(bb1)
			ff = set(cc1).intersection(dd1)
			if ee != set():
				if cc1 == [] and dd1 == []:
					print(a - xxx)
					print(-1, -1)
					quit()
				print(a - xxx - 1)
				if len(cc1) > 0:
					print(list(ee)[0], cc1[0])
				else:
					print(list(ee)[0], dd1[0])
				quit()
			elif ff != set():
				if aa1 == [] and bb1 == []:
					print(a - xxx)
					print(-1, -1)
					quit()
				print(a - xxx - 1)
				if len(aa1) > 0:
					print(list(ff)[0], aa1[0])
				else:
					print(list(ff)[0], bb1[0])
				quit()
print(a - xxx)
print(-1, -1)


n = int(input())
s = input()
t = input()
(k, l) = (0, 0)
state = 0
hd = 0
m = {}
for i in range(n):
	if s[i] != t[i]:
		hd += 1
		cs = s[i]
		ct = t[i]
		cst = cs + ct
		if cst not in m:
			m[cst] = i + 1
for pair in m:
	r = pair[1] + pair[0]
	if r in m:
		print(hd - 2)
		print(m[pair], m[r])
		exit()
for pair in m:
	for p in m:
		if pair == p:
			continue
		if p[0] == pair[1] or p[1] == pair[0]:
			print(hd - 1)
			print(m[pair], m[p])
			exit()
print(hd)
print(-1, -1)


n = input()
(s1, s2) = (input(), input())
l1 = [[x, [s1[x], s2[x]]] for x in range(len(s1)) if s1[x] != s2[x]]
(d1, d2) = (dict([(y[1][0] + y[1][1], y[0]) for y in l1]), dict([(y[1][1] + y[1][0], y[0]) for y in l1]))
ins = set(d1.keys()) & set(d2.keys())
if ins:
	e = ins.pop()
	print(len(l1) - 2)
	print(d1[e] + 1, d2[e] + 1)
	exit(0)
(s1, s2) = (dict([(y[1][0], y[0]) for y in l1]), dict([(y[1][1], y[0]) for y in l1]))
ins = set(s1.keys()) & set(s2.keys())
if ins:
	e = ins.pop()
	print(len(l1) - 1)
	print(s1[e] + 1, s2[e] + 1)
	exit(0)
print(len(l1))
print(-1, -1)


n = int(input())
s = list(input())
t = list(input())
d = {}
ans = 0
(x, y) = (-1, -1)
for i in range(n):
	if s[i] != t[i]:
		d[s[i], t[i]] = i
		ans += 1
l = [chr(i + 97) for i in range(26)]
for i in l:
	for j in l:
		if (i, j) in d and (j, i) in d:
			ans -= 2
			x = d[i, j] + 1
			y = d[j, i] + 1
			break
	if x != -1:
		break
if x == y == -1:
	for i in l:
		for j in l:
			for k in l:
				if (i, j) in d and (j, k) in d:
					ans -= 1
					x = d[i, j] + 1
					y = d[j, k] + 1
					break
		if x != -1:
			break
print(ans)
print(x, y)


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

def ff(ch):
	return ord(ch) - ord('a')

def answer(a, b, sc):
	print(cans + sc)
	print(a + 1, b + 1)
	exit()
cans = 0
matrix = [[None] * 26 for i in range(26)]
for i in range(n):
	matrix[ff(s[i])][ff(t[i])] = i
	if s[i] != t[i]:
		cans += 1
for i in range(26):
	for j in range(i):
		if matrix[i][j] is not None and matrix[j][i] is not None:
			answer(matrix[i][j], matrix[j][i], -2)
for i in range(26):
	for h in range(26):
		if h == i:
			continue
		for v in range(26):
			if v == i:
				continue
			if matrix[h][i] is not None and matrix[i][v] is not None:
				answer(matrix[h][i], matrix[i][v], -1)
answer(-2, -2, 0)


diff = []
wrong_t = {}

def distance(n, s, t):
	count = 0
	for i in range(n):
		if s[i] != t[i]:
			diff.append(i)
			wrong_t[t[i]] = i
			count += 1
	return count

def minDistance():
	m_ben = 0
	m_i = -2
	m_j = -2
	for i in diff:
		v = wrong_t[s[i]] if s[i] in wrong_t else None
		if v != None:
			m_ben = 1
			m_i = i
			m_j = v
			if s[v] == t[i]:
				return (2, i, v)
	return (m_ben, m_i, m_j)
n = int(input())
s = input()
t = input()
d = distance(n, s, t)
(m_ben, m_i, m_j) = minDistance()
print(d - m_ben)
print('{0} {1}'.format(m_i + 1, m_j + 1))


def main():
	n = int(input())
	(s, t) = (str(input()), str(input()))
	p = [[0] * 26 for _ in range(26)]
	dist = 0
	for i in range(n):
		if s[i] != t[i]:
			j = ord(s[i]) - ord('a')
			k = ord(t[i]) - ord('a')
			p[j][k] = i + 1
			dist += 1
	for i in range(26):
		for j in range(26):
			if i != j and p[i][j] > 0 and (p[j][i] > 0):
				print(dist - 2)
				print(p[i][j], p[j][i])
				return
	for i in range(26):
		for j in range(26):
			if i != j and p[i][j] > 0 and (max(p[j]) > 0):
				print(dist - 1)
				for k in range(26):
					if p[j][k] > 0:
						print(p[i][j], p[j][k])
						return
	print(dist)
	print(-1, -1)

def __starting_point():
	main()
__starting_point()


import sys
n = int(input())
a = input()
b = input()
l = 0
c = [[0 for j in range(26)] for i in range(26)]
for i in range(n):
	if a[i] != b[i]:
		l += 1
		c[ord(a[i]) - ord('a')][ord(b[i]) - ord('a')] = i + 1
for i in range(26):
	for j in range(26):
		if i == j or c[i][j] == 0 or c[j][i] == 0:
			continue
		print(l - 2)
		print(c[i][j], c[j][i])
		sys.exit(0)
for i in range(26):
	for j in range(26):
		if i == j or c[i][j] == 0 or max(c[j]) == 0:
			continue
		print(l - 1)
		print(c[i][j], end=' ')
		for k in range(26):
			if c[j][k] > 0:
				print(c[j][k])
		sys.exit(0)
print(l)
print(-1, -1)


from pprint import pprint
from operator import itemgetter

def main():
	_ = int(input().strip())
	w1 = input().strip()
	w2 = input().strip()
	if len(w1) != len(w2):
		return -1
	(hdis, fpos, lpos) = one_replace_hamming(w1, w2)
	print(hdis)
	print(min(fpos + 1, lpos + 1), max(fpos + 1, lpos + 1))

def ham_wt(w1, w2):
	diff_pairs1 = []
	rev_assoc = dict()
	pos_indicator = dict()
	for i in range(len(w1)):
		if w2[i] != w1[i]:
			diff_pairs1.append((w1[i], w2[i]))
			rev_assoc[w2[i]] = w1[i]
			pos_indicator[w1[i], w2[i]] = i
	return (diff_pairs1, rev_assoc, pos_indicator)

def one_replace_hamming(w1, w2):
	(diff_pairs, rev_assoc, pos_indicator) = ham_wt(w1, w2)
	for (fst, snd) in diff_pairs:
		if fst in rev_assoc and rev_assoc[fst] == snd:
			return (len(diff_pairs) - 2, pos_indicator[fst, snd], pos_indicator[snd, fst])
	for (fst, snd) in diff_pairs:
		if fst in rev_assoc:
			return (len(diff_pairs) - 1, pos_indicator[fst, snd], pos_indicator[rev_assoc[fst], fst])
	return (len(diff_pairs), -2, -2)
main()


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

def id(c):
	return ord(c) - ord('a')
diff = 0
for i in range(n):
	if s[i] != t[i]:
		diff += 1
has = [[0 for i in range(30)] for j in range(30)]
x = [0 for i in range(30)]
y = [0 for i in range(30)]
if diff == 0:
	print('0\n-1 -1')
elif diff == 1:
	print('1\n-1 -1')
else:
	for i in range(n):
		if s[i] != t[i] and has[id(s[i])][id(t[i])]:
			print('{} \n{} {}'.format(diff - 2, has[id(s[i])][id(t[i])], i + 1))
			quit()
		has[id(t[i])][id(s[i])] = i + 1
	for i in range(n):
		if x[id(s[i])] != 0 and s[i] != t[i]:
			print('{} \n{} {}'.format(diff - 1, x[id(s[i])], i + 1))
			quit()
		if y[id(t[i])] != 0 and s[i] != t[i]:
			print('{} \n{} {}'.format(diff - 1, y[id(t[i])], i + 1))
			quit()
		if s[i] != t[i]:
			x[id(t[i])] = y[id(s[i])] = i + 1
	print('{} \n{} {}'.format(diff, -1, -1))


n = int(input())
(s, t) = (input(), input())
alpha = list('abcdefghijklmnopqrstuvwxyz')
(spair, tpair) = (dict(), dict())
x = [1] * n
k = n
d = 0
(u, v) = (-1, -1)
dd = dict()
for i in range(n):
	if s[i] == t[i]:
		k = k - 1
	else:
		dd[s[i] + t[i]] = str(i + 1)
for i in alpha:
	for j in alpha:
		if i + j in dd and j + i in dd:
			print(k - 2)
			print(dd[i + j] + ' ' + dd[j + i])
			raise SystemExit
for i in alpha:
	for j in alpha:
		for l in alpha:
			if i + j in dd and j + l in dd:
				print(k - 1)
				print(dd[i + j] + ' ' + dd[j + l])
				raise SystemExit
print(k)
print('-1 -1')


def main():
	from collections import defaultdict
	n = int(input())
	(flag, res, pairs, pair) = (True, 0, {}, None)
	(missa, missb) = (defaultdict(int), defaultdict(int))
	for (i, a, b) in zip(range(1, n + 1), input(), input()):
		if a != b:
			res += 1
			if flag:
				if a + b in pairs:
					flag = False
					pair = (pairs[a + b], i)
				else:
					if pair is None:
						j = missb[a] or missa[b]
						if j:
							pair = (j, i)
						else:
							missa[a] = missb[b] = i
					pairs[b + a] = i
	print(res - (pair is not None if flag else 2))
	print(*((-1, -1) if pair is None else pair))
main()


n = int(input())
s = input()
t = input()
dis = 0
d = [[False for i in range(30)] for i in range(30)]
x = [[0 for i in range(30)] for i in range(30)]
for i in range(n):
	if s[i] != t[i]:
		dis += 1
		d[ord(s[i]) - ord('a')][ord(t[i]) - ord('a')] = True
		x[ord(s[i]) - ord('a')][ord(t[i]) - ord('a')] = i + 1

def progress():
	for i in range(26):
		for j in range(26):
			if d[i][j] and d[j][i]:
				print('{}\n{} {}'.format(dis - 2, x[i][j], x[j][i]))
				return 0
	for i in range(26):
		for j in range(26):
			if d[i][j]:
				for t in range(26):
					if d[j][t]:
						print('{}\n{} {}'.format(dis - 1, x[i][j], x[j][t]))
						return 0
	print('{}\n{} {}'.format(dis, -1, -1))
progress()


import time

class Profiler(object):

	def __enter__(self):
		self._startTime = time.time()

	def __exit__(self, type, value, traceback):
		print('Elapsed time: {:.3f} sec'.format(time.time() - self._startTime))
n = int(input())
a = input()
b = input()
indexes = list()
d = {}
f1 = False
f2 = False
df = 0
i1 = 0
i2 = 0
for i in range(n):
	if a[i] != b[i]:
		df += 1
		indexes.append(i)
		d[b[i]] = i
for i in indexes:
	if a[i] in d:
		f1 = True
		j = d[a[i]]
		i1 = i + 1
		i2 = j + 1
		if a[j] == b[i]:
			f2 = True
			break
if f2:
	print(str(df - 2))
	print(i1.__str__() + ' ' + i2.__str__())
elif f1:
	print(str(df - 1))
	print(i1.__str__() + ' ' + i2.__str__())
else:
	print(str(df))
	print('-1 -1')


num = int(input())
a = input()
b = input()
dic = {}
lis = []
ham = 0
swap1 = -1
swap2 = -1
p = False
q = False
for i in range(num):
	if a[i] != b[i]:
		ham += 1
		lis.append(i)
		dic[b[i]] = i
for i in lis:
	if a[i] in dic:
		p = True
		swap1 = i + 1
		f = dic[a[i]]
		swap2 = f + 1
		if a[f] == b[i]:
			q = True
			break
print(ham - (2 if q else 1 if p else 0))
print(swap1, swap2)


def main():
	n = int(input())
	s = input()
	t = input()
	p = {}
	hd = sum((int(x != y) for (x, y) in zip(s, t)))
	for (i, (x, y)) in enumerate(zip(s, t)):
		if x != y:
			if x in p and y in p[x]:
				print(hd - 2)
				print(i + 1, p[x][y] + 1)
				return
			else:
				if y not in p:
					p[y] = {}
				p[y][x] = i
	for x in p:
		c = p.keys() & p[x].keys()
		if c:
			print(hd - 1)
			c = c.pop()
			print(p[x][c] + 1, p[c].popitem()[1] + 1)
			return
	print(hd)
	print(-1, -1)
main()


n = int(input())
s = input()
t = input()
diff = {}
dis = 0
for i in range(len(s)):
	if s[i] != t[i]:
		dis += 1
		diff[s[i] + t[i]] = i + 1
for d in diff.keys():
	if diff.get(d[::-1], 0) > 0:
		print(dis - 2)
		print(diff[d], diff[d[::-1]])
		exit()
for d in diff.keys():
	for dd in diff.keys():
		if d[0] == dd[1] or d[1] == dd[0]:
			print(dis - 1)
			print(diff[d], diff[dd])
			exit()
print(dis)
print(-1, -1)


import string
(n, s, t) = (int(input()), input(), input())
(x, i, j) = (0, -1, -1)
sc_dict = {c: set() for c in string.ascii_lowercase}
tc_dict = {c: set() for c in string.ascii_lowercase}
(sti_dict, tsi_dict) = (dict(), dict())
for (ci, sc, tc) in zip(list(range(n)), s, t):
	if sc == tc:
		continue
	sc_dict[sc].add(tc)
	tc_dict[tc].add(sc)
	sti_dict[sc + tc] = ci
	tsi_dict[tc + sc] = ci
	x += 1
for c in string.ascii_lowercase:
	cs = sc_dict[c] & tc_dict[c]
	if not cs:
		continue
	c2 = cs.pop()
	x -= 2
	i = sti_dict[c + c2] + 1
	j = tsi_dict[c + c2] + 1
	break
else:
	for c in string.ascii_lowercase:
		if not sc_dict[c] or not tc_dict[c]:
			continue
		x -= 1
		i = sti_dict[c + sc_dict[c].pop()] + 1
		j = tsi_dict[c + tc_dict[c].pop()] + 1
		break
print(x)
print(i, j)


n = int(input())
s = input()
t = input()
p = 0
dist = 0
m = [[] for i in range(0, 26)]
sr = []
while p < len(s):
	if s[p] != t[p]:
		m[ord(s[p]) - ord('a')].append((t[p], p))
		dist += 1
	p += 1
p = 0
while p < len(s):
	if s[p] != t[p]:
		flag = False
		for i in sr:
			if i[0] == s[p] and i[1] == t[p]:
				flag = True
				break
		if flag == True:
			p += 1
			continue
		sr.append((s[p], t[p]))
		for i in m[ord(t[p]) - ord('a')]:
			if i[0] == s[p]:
				dist -= 2
				print(dist)
				print(p + 1, i[1] + 1)
				quit()
	p += 1
p = 0
while p < len(s):
	if s[p] != t[p]:
		if len(m[ord(t[p]) - ord('a')]) > 0:
			dist -= 1
			print(dist)
			print(p + 1, m[ord(t[p]) - ord('a')][0][1] + 1)
			quit()
	p += 1
print(dist)
print(-1, -1)


n = int(input())
s = input()
t = input()
a = []
x = y = -2
h = 0
for i in range(26):
	a.append([])
	for j in range(26):
		a[i].append(-1)
for i in range(n):
	if s[i] != t[i]:
		h += 1
		a[ord(s[i]) - ord('a')][ord(t[i]) - ord('a')] = i
		if a[ord(t[i]) - ord('a')][ord(s[i]) - ord('a')] != -1:
			x = i
			y = a[ord(t[i]) - ord('a')][ord(s[i]) - ord('a')]
if x == -2:
	for i in range(26):
		for j in range(26):
			if a[i][j] != -1:
				for k in range(26):
					if a[j][k] != -1:
						x = a[i][j]
						y = a[j][k]
if x != -2:
	if s[x] == t[y]:
		h -= 1
	if s[y] == t[x]:
		h -= 1
print(h)
print(x + 1, y + 1)


alth = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
S = input()
T = input()
heming = 0
first = [-1] * 26
second = [-1] * 26
first_second = [-1] * 676
for i in range(n):
	if S[i] != T[i]:
		heming += 1
		temp = alth.find(S[i])
		temp2 = alth.find(T[i])
		first[temp] = i
		second[temp2] = i
		first_second[temp * 26 + temp2] = i
error_1 = 0
error_2 = 0
for i in range(676):
	temp = i % 26
	temp2 = i // 26
	if first_second[i] != -1 and first_second[temp * 26 + temp2] != -1:
		error_1 = 1
		print(heming - 2)
		print(first_second[i] + 1, first_second[temp * 26 + temp2] + 1)
		break
if error_1 == 0:
	for i in range(26):
		if first[i] != -1 and second[i] != -1:
			error_2 = 2
			print(heming - 1)
			print(first[i] + 1, second[i] + 1)
			break
	if error_2 == 0:
		print(heming)
		print(-1, -1)


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

def ff(ch):
	return ord(ch) - ord('a')

def answer(a, b, sc):
	print(res + sc)
	print(a + 1, b + 1)
	return
matrix = [[None] * 26 for _ in range(26)]
res = 0
for i in range(len(s)):
	matrix[ff(s[i])][ff(t[i])] = i
	if s[i] != t[i]:
		res += 1
for i in range(26):
	for j in range(i):
		if matrix[i][j] is not None and matrix[j][i] is not None:
			answer(matrix[i][j], matrix[j][i], -2)
for i in range(26):
	for h in range(26):
		if h == i:
			continue
		for v in range(26):
			if v == i:
				continue
			if matrix[h][i] is not None and matrix[i][v] is not None:
				answer(matrix[h][i], matrix[i][v], -1)
answer(-2, -2, 0)


(n, s, t) = (int(input()), input(), input())
d = {}
wrongs = []
(ansD, ansI, ansJ) = (0, -1, -1)
for i in range(n):
	if s[i] != t[i]:
		ansD += 1
		wrongs.append(i)
		d[t[i]] = i
perfectSwapped = False
swapped = False
for i in wrongs:
	if s[i] in d:
		swapped = True
		ansI = i + 1
		j = d[s[i]]
		ansJ = j + 1
		if s[j] == t[i]:
			perfectSwapped = True
			break
print(ansD - (2 if perfectSwapped else 1 if swapped else 0))
print(ansI, ansJ)


YNaXbdBeHKpwfIm = int
YNaXbdBeHKpwfIi = input
YNaXbdBeHKpwfIj = range
YNaXbdBeHKpwfIR = len
YNaXbdBeHKpwfID = print
YNaXbdBeHKpwfIl = exit
YNaXbdBeHKpwfIt = YNaXbdBeHKpwfIm
YNaXbdBeHKpwfIx = YNaXbdBeHKpwfIi
YNaXbdBeHKpwfIz = YNaXbdBeHKpwfIj
YNaXbdBeHKpwfIW = YNaXbdBeHKpwfIR
YNaXbdBeHKpwfIO = YNaXbdBeHKpwfID
YNaXbdBeHKpwfIo = YNaXbdBeHKpwfIl
YNaXbdBeHKpwfIM = YNaXbdBeHKpwfIt
YNaXbdBeHKpwfIn = YNaXbdBeHKpwfIx
YNaXbdBeHKpwfIL = YNaXbdBeHKpwfIz
YNaXbdBeHKpwfIA = YNaXbdBeHKpwfIW
YNaXbdBeHKpwfIq = YNaXbdBeHKpwfIO
YNaXbdBeHKpwfIc = YNaXbdBeHKpwfIo
n = YNaXbdBeHKpwfIM(YNaXbdBeHKpwfIn())
s = YNaXbdBeHKpwfIn()
t = YNaXbdBeHKpwfIn()
YNaXbdBeHKpwfIs = {}
YNaXbdBeHKpwfIT = 0
for i in YNaXbdBeHKpwfIL(YNaXbdBeHKpwfIA(s)):
	if s[i] != t[i]:
		YNaXbdBeHKpwfIT += 1
		YNaXbdBeHKpwfIs[s[i] + t[i]] = i + 1
for d in YNaXbdBeHKpwfIs.keys():
	if YNaXbdBeHKpwfIs.get(d[::-1], 0) > 0:
		YNaXbdBeHKpwfIq(YNaXbdBeHKpwfIT - 2)
		YNaXbdBeHKpwfIq(YNaXbdBeHKpwfIs[d], YNaXbdBeHKpwfIs[d[::-1]])
		YNaXbdBeHKpwfIc()
for d in YNaXbdBeHKpwfIs.keys():
	for dd in YNaXbdBeHKpwfIs.keys():
		if d[0] == dd[1] or d[1] == dd[0]:
			YNaXbdBeHKpwfIq(YNaXbdBeHKpwfIT - 1)
			YNaXbdBeHKpwfIq(YNaXbdBeHKpwfIs[d], YNaXbdBeHKpwfIs[dd])
			YNaXbdBeHKpwfIc()
YNaXbdBeHKpwfIq(YNaXbdBeHKpwfIT)
YNaXbdBeHKpwfIq(-1, -1)


import unittest

def solve(S, T):
	pos_s = {}
	pos_t = {}
	wrongs = []
	distance = 0
	for (i, (s, t)) in enumerate(zip(S, T)):
		if s != t:
			pos_t[s, t] = i
			pos_s[s] = i
			wrongs.append((s, t, i))
			distance += 1
	for (wrong, need, i) in wrongs:
		j = pos_t.get((need, wrong))
		if j is not None:
			return (distance - 2, i + 1, j + 1)
	for (wrong, need, i) in wrongs:
		if need in pos_s:
			return (distance - 1, i + 1, pos_s[need] + 1)
	return (distance, -1, -1)

class Test_solution(unittest.TestCase):

	def test_case(self):
		self.assertEqual(solve('pergament', 'permanent'), (1, 4, 6))
		self.assertEqual(solve('wookie', 'cookie'), (1, -1, -1))
		self.assertEqual(solve('petr', 'egor'), (2, 1, 2))
		self.assertEqual(solve('double', 'bundle'), (2, 1, 4))
		self.assertEqual(solve('', ''), (0, -1, -1))
input()
S = input()
T = input()
(distance, i, j) = solve(S, T)
print(distance)
print(i, j)


n = int(input())
s = input()
t = input()
pair2ind = {}
letters_s = [0] * 26
letters_t = [0] * 26
non_common = set()
cnt = 0
for i in range(n):
	if s[i] != t[i]:
		pair2ind[s[i], t[i]] = i + 1
		letters_s[ord(s[i]) - ord('a')] = i + 1
		letters_t[ord(t[i]) - ord('a')] = i + 1
		non_common.add(i + 1)
		cnt += 1
sim = -1
for i in range(26):
	if letters_s[i] != 0 and letters_t[i] != 0:
		sim = letters_s[i]
		break
else:
	print(cnt)
	print(-1, -1)
	exit()
for i in range(n):
	if s[i] != t[i]:
		if (t[i], s[i]) in pair2ind:
			print(cnt - 2)
			print(pair2ind[s[i], t[i]], pair2ind[t[i], s[i]])
			exit()
non_common.remove(sim)
print(cnt - 1)
print(sim, letters_t[ord(s[sim - 1]) - ord('a')])
exit()


(n, s, t) = (int(input()), input(), input())
t_dict = dict()
diffs = list()
(res_i, res_j) = (-1, -1)
res_d = 0
for i in range(n):
	if s[i] == t[i]:
		continue
	res_d += 1
	diffs.append(i)
	t_dict[t[i]] = i
perfect_swapped = False
swapped = False
for i in diffs:
	if s[i] not in t_dict:
		continue
	swapped = True
	res_i = i + 1
	j = t_dict[s[i]]
	res_j = j + 1
	if s[j] == t[i]:
		perfect_swapped = True
		break
print(res_d - (2 if perfect_swapped else 1 if swapped else 0))
print(res_i, res_j)


n = input()
(s1, s2) = (input(), input())
(l2, l3) = ([], [])
l1 = [[l2.append((s1[x] + s2[x], x)), l3.append((s2[x] + s1[x], x))] for x in range(len(s1)) if s1[x] != s2[x]]
(d1, d2) = (dict(l2), dict(l3))
ins = set(d1.keys()) & set(d2.keys())
if ins:
	e = ins.pop()
	print(len(l1) - 2)
	print(d1[e] + 1, d2[e] + 1)
	return
(s1, s2) = ({y[0][0]: y[1] for y in l2}, {y[0][1]: y[1] for y in l2})
ins = set(s1.keys()) & set(s2.keys())
if ins:
	e = ins.pop()
	print(len(l1) - 1)
	print(s1[e] + 1, s2[e] + 1)
	return
print(len(l1))
print(-1, -1)


import sys
n = int(input())
s = input()
t = input()
arr = {}
f = 0
for idx in range(n):
	if s[idx] != t[idx]:
		f += 1
		arr[s[idx] + t[idx]] = idx
for k in arr.keys():
	if k[1] + k[0] in arr:
		print(f - 2)
		print(str(arr[k] + 1) + ' ' + str(arr[k[1] + k[0]] + 1))
		sys.exit(0)
for k in arr.keys():
	for l in arr.keys():
		if k[0] == l[1] or k[1] == l[0]:
			print(f - 1)
			print(str(arr[k] + 1) + ' ' + str(arr[l] + 1))
			sys.exit(0)
print(f)
print('-1 -1')


__author__ = 'ruckus'
n = int(input())
s = input()
t = input()
dif = {}
hem = 0
for i in range(n):
	if s[i] != t[i]:
		dif[i] = [s[i], t[i]]
		hem += 1
change = []
probed = []
k = 0
for i in dif.keys():
	if dif[i] in probed:
		continue
	probed.append(dif[i])
	k += 1
	for j in list(dif.keys())[k:]:
		if dif[i] == dif[j][::-1]:
			print(hem - 2)
			print(i + 1, j + 1)
			quit()
		if not change and (dif[i][0] == dif[j][1] or dif[j][0] == dif[i][1]):
			change = [i, j]
if change:
	print(hem - 1)
	print(change[0] + 1, change[1] + 1)
else:
	print(hem)
	print('-1 -1')


from sys import stdin, stdout
from collections import Counter

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

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

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

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
s = input()
t = input()
value = {}
li = []
res1 = 0
res2 = res3 = -1
for i in range(n):
	if s[i] != t[i]:
		value[t[i]] = i
		res1 += 1
		li.append(i)
p = sq = False
for i in li:
	if s[i] in value:
		p = True
		res2 = i + 1
		f = value[s[i]]
		res3 = f + 1
		if s[f] == t[i]:
			sq = True
			break
print(res1 - (2 if sq else 1 if p else 0))
print(res2, res3)


n = int(input())
s = input()
t = input()
p = [-1, -1]
a = [[-1] * 26 for i in range(26)]
k = 0
for i in range(n):
	if t[i] != s[i]:
		k += 1
for i in range(n):
	if t[i] != s[i]:
		if a[ord(t[i]) - 97][ord(s[i]) - 97] != -1:
			print(k - 2)
			print(a[ord(t[i]) - 97][ord(s[i]) - 97] + 1, i + 1)
			exit()
		a[ord(s[i]) - 97][ord(t[i]) - 97] = i
for i in range(n):
	if t[i] != s[i]:
		for j in range(26):
			if a[j][ord(s[i]) - 97] != -1:
				print(k - 1)
				print(a[j][ord(s[i]) - 97] + 1, i + 1)
				exit()
		a[ord(s[i]) - 97][ord(t[i]) - 97] = i
print(k)
print(-1, -1)


(n, s, t, a, error, ans, kappa) = (int(input()), str(input()), str(input()), {}, 0, -1, 0)
for i in range(n):
	if s[i] != t[i]:
		a[s[i] + t[i]] = i
		error += 1
for c1 in 'abcdefghijklmnopqrstuvwxyz':
	for c2 in 'abcdefghijklmnopqrstuvwxyz':
		if c1 == c2 or kappa == 2:
			continue
		if c1 + c2 in a and c2 + c1 in a and (kappa < 2):
			ans = (a[c1 + c2], a[c2 + c1])
			kappa = 2
		if kappa == 0:
			for c3 in 'abcdefghijklmnopqrstuvwxyz':
				if c1 != c3 and c1 + c2 in a and (c2 + c3 in a):
					ans = (a[c1 + c2], a[c2 + c3])
					kappa = 1
print(error - kappa)
print('%d %d' % ((ans[0] + 1, ans[1] + 1) if ans != -1 else (-1, -1)))


n = int(input())
a = input()
b = input()
cnt = 0
index1 = -1
index2 = -1
mp = {}
flag1 = True
flag2 = True
l = [chr(ord('a') + i) for i in range(26)]
for i in range(n):
	if a[i] != b[i]:
		cnt += 1
		mp[a[i], b[i]] = i
for i in l:
	if flag1:
		for j in l:
			if flag1:
				if (i, j) in mp:
					if (j, i) in mp:
						index1 = mp[i, j] + 1
						index2 = mp[j, i] + 1
						flag1 = False
					else:
						for k in l:
							if (j, k) in mp:
								index1 = mp[i, j] + 1
								index2 = mp[j, k] + 1
								flag2 = False
							elif (k, i) in mp:
								index1 = mp[i, j] + 1
								index2 = mp[k, i] + 1
								flag2 = False
print(cnt - (2 if flag1 == False else 1 if flag2 == False else 0))
print(index1, index2)


n = int(input())
s = input()
t = input()
q = {}
osh = []
rez1 = 0
rez2 = -1
rez3 = -1
for i in range(n):
	if s[i] != t[i]:
		rez1 += 1
		osh.append(i)
		q[t[i]] = i
p = False
sq = False
for i in osh:
	if s[i] in q:
		p = True
		rez2 = i + 1
		f = q[s[i]]
		rez3 = f + 1
		if s[f] == t[i]:
			sq = True
			break
print(rez1 - (2 if sq else 1 if p else 0))
print(rez2, rez3)


def gao():
	n = int(input())
	a = input()
	b = input()
	mp = {}
	cnt = 0
	for i in range(n):
		if a[i] != b[i]:
			cnt += 1
			mp[a[i], b[i]] = i + 1
	l = [chr(ord('a') + i) for i in range(26)]
	for i in l:
		for j in l:
			if (i, j) in mp and (j, i) in mp:
				print(cnt - 2)
				print(mp[i, j], mp[j, i])
				return
	for i in l:
		for j in l:
			for k in l:
				if (i, j) in mp and (j, k) in mp:
					print(cnt - 1)
					print(mp[i, j], mp[j, k])
					return
	print(cnt)
	print(-1, -1)
gao()


(_, s, t) = (input(), input(), input())
d = 0
p = [[-1 for _ in range(26)] for _ in range(26)]
(a, b) = ([-1 for _ in range(26)], [-1 for _ in range(26)])
for i in range(len(s)):
	if s[i] != t[i]:
		cs = ord(s[i]) - 97
		ct = ord(t[i]) - 97
		d += 1
		p[cs][ct] = i + 1
		a[cs] = i + 1
		b[ct] = i + 1
for i in range(26 * 26):
	if p[i // 26][i % 26] > -1 and p[i % 26][i // 26] > -1:
		print(d - 2)
		print(p[i // 26][i % 26], p[i % 26][i // 26])
		break
else:
	for i in range(26):
		if a[i] > -1 and b[i] > -1:
			print(d - 1)
			print(a[i], b[i])
			break
	else:
		print(d)
		print(-1, -1)


def solve(n, S, T):
	st = dict()
	ts = dict()
	s = dict()
	t = dict()
	dist = 0
	for (i, (si, ti)) in enumerate(zip(S, T), 1):
		if si != ti:
			st[si, ti] = i
			ts[ti, si] = i
			s[si] = i
			t[ti] = i
			dist += 1
	for (key, i) in st.items():
		if key in ts:
			j = ts[key]
			return (dist - 2, min(i, j), max(i, j))
	for (si, i) in s.items():
		if si in t:
			j = t[si]
			return (dist - 1, min(i, j), max(i, j))
	return (dist, -1, -1)
n = int(input())
S = input()
T = input()
(dist, i, j) = solve(n, S, T)
print(dist)
print(i, j)


from collections import defaultdict
from itertools import product
n = int(input())
a = input()
b = input()
mp = {}
cnt = 0
for i in range(n):
	if a[i] != b[i]:
		cnt += 1
		mp[a[i], b[i]] = i + 1
l = [x for x in set(a) | set(b)]
ct = f = s = None
for (i, j) in product(l, l):
	if (i, j) in mp and (j, i) in mp:
		(ct, f, s) = (cnt - 2, mp[i, j], mp[j, i])
if ct is None:
	for (i, j, k) in product(l, l, l):
		if (i, j) in mp and (j, k) in mp:
			(ct, f, s) = (cnt - 1, mp[i, j], mp[j, k])
if ct is None:
	(ct, f, s) = (cnt, -1, -1)
print('%d\n%d %d' % (ct, f, s))


def solve():
	r = 0
	d = {}
	for i in range(n):
		if a[i] != b[i]:
			r += 1
			d[a[i], b[i]] = i + 1
	symbols = [chr(ord('a') + i) for i in range(26)]
	for i in symbols:
		for j in symbols:
			if (i, j) in d and (j, i) in d:
				return (r - 2, d[i, j], d[j, i])
	for i in symbols:
		for j in symbols:
			for k in symbols:
				if (i, j) in d and (j, k) in d:
					return (r - 1, d[i, j], d[j, k])
	return (r, -1, -1)
n = int(input())
a = input()
b = input()
ans = solve()
print(ans[0], '\n', ans[1], ' ', ans[2], sep='')