#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
int n, p[MAXN], p1[MAXN];
set<int> v[MAXN], v1[MAXN];
vector<pair<int, int> > sol, E[MAXN];
void check(int x) {
  if (p[x] != p1[x]) return;
  v[p[x]].erase(x);
  v1[p1[x]].erase(x);
}
void Swap(int a, int b) {
  sol.push_back({a + 1, b + 1});
  v[p[a]].erase(a);
  v1[p1[b]].erase(b);
  swap(p[a], p1[b]);
  v[p[a]].insert(a);
  v1[p1[b]].insert(b);
  check(a);
  check(b);
}
int get1(int x, int y) { return *v[x].lower_bound(y); }
int get2(int x, int y) { return *v1[x].lower_bound(y); }
bool probaj(int x, bool y) {
  int t = get1(p[x], x + 1);
  if (t == MAXN) return 0;
  if (y)
    Swap(x, t);
  else
    Swap(t, x);
  return 1;
}
bool probaj1(int x, bool y) {
  int t = get2(p1[x], x + 1);
  if (t == MAXN) return 0;
  if (y)
    Swap(t, x);
  else
    Swap(x, t);
  return 1;
}
bool bio[MAXN];
char P[MAXN], P1[MAXN];
int main() {
  scanf("%d", &n);
  scanf("%s %s", P, P1);
  for (int i = (0); i < int(n); i++) {
    p[i] = P[i] - 'a';
    v[p[i]].insert(i);
  }
  for (int i = (0); i < int(n); i++) {
    p1[i] = P1[i] - 'a';
    v1[p1[i]].insert(i);
  }
  for (int i = (0); i < int(n); i++) check(i);
  for (int i = (0); i < int(MAXN); i++) {
    v[i].insert(MAXN);
    v1[i].insert(MAXN);
  }
  int cnt = 0;
  for (int i = (0); i < int(n); i++) {
    cnt++;
    if (cnt > 5 * n) {
      puts("-1");
      return 0;
    }
    if (p[i] == p1[i]) continue;
    if (probaj(i, bio[i])) {
      if (p[i] != p1[i]) i--;
      continue;
    }
    if (probaj1(i, bio[i])) {
      if (p[i] != p1[i]) i--;
      continue;
    }
    bio[i] = 1;
    if (v[p[i]].size() == 2) Swap(i, i);
    if (p[i] != p1[i]) i--;
  }
  printf("%d\n", (int)sol.size());
  for (auto t : sol) printf("%d %d\n", t.first, t.second);
  for (int i = (0); i < int(n); i++) assert(p[i] == p1[i]);
  return 0;
}
