链接:https://codeforces.com/contest/1215/problem/C

Monocarp has got two strings ss and tt having equal length. Both strings consist of lowercase Latin letters "a" and "b".

Monocarp wants to make these two strings ss and tt equal to each other. He can do the following operation any number of times: choose an index pos1pos1 in the string ss, choose an index pos2pos2 in the string tt, and swap spos1spos1 with tpos2tpos2.

You have to determine the minimum number of operations Monocarp has to perform to make ss and tt 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 nn (1≤n≤2⋅105)(1≤n≤2⋅105) — the length of ss and tt.

The second line contains one string ss consisting of nn characters "a" and "b".

The third line contains one string tt consisting of nn characters "a" and "b".

Output

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

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

Examples

input

Copy

4
abab
aabb

output

Copy

2
3 3
3 2

input

Copy

1
a
b

output

Copy

-1

input

Copy

8
babbaabb
abababaa

output

Copy

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 ss with the third letter in tt. Then s=s= "abbb", t=t= "aaab". Then swap the third letter in ss and the second letter in tt. Then both ss and tt are equal to "abab".

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

思路:

先直接遍历,找到第一个不同点然后往后找找到可以一步换成功的点,直接换掉并存下调换下标

,如果找不到,则直接上下交换继续上一步操作,如果此时还不能找到,输出-1

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int maxn=1e6+5;
long long n,s=0;
char a[200005],b[200005];
int c[200005],d[200005];
int main()
{
	scanf("%lld",&n);
	scanf("%s",a);
	scanf("%s",b);
	int fl=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i])
		continue;
		else
		{
			int flag=0;
			for(int j=i+1;j<n;j++)
			{
				if(b[i]==b[j]&&a[j]!=b[j])
				{
					s++;
					a[i]=b[i];
					a[j]=b[j];
					c[s]=i+1;
					d[s]=j+1;
					flag=1;
					fl=1;
					break;
				}
			}
			if(flag==0&&fl==1)
			{
				s++;
				char x;
				x=a[i];
				a[i]=b[i];
				b[i]=x;
				c[s]=i+1;
				d[s]=i+1;
				i--;
				fl=0;
			}
			else if(flag==0&&fl==0)
			{
				s=-1;
				break;
			}
		}
	}
	printf("%lld\n",s);
	for(int i=1;i<=s;i++)
	{
		printf("%d %d\n",c[i],d[i]);
	}
}