#include <bits/stdc++.h>
using namespace std;
queue<int> a[2][40], q[2];
char aj[150010], bj[150010];
int main() {
  int n;
  scanf("%d%s%s", &n, aj, bj);
  for (int i = 0; i < n; i++) {
    if (aj[i] != '?')
      a[0][aj[i] - 'a'].push(i);
    else
      q[0].push(i);
    if (bj[i] != '?')
      a[1][bj[i] - 'a'].push(i);
    else
      q[1].push(i);
  }
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    cnt += min(a[1][i].size(), a[0][i].size());
  }
  int qs = q[0].size() + q[1].size();
  cnt += min(qs, n - cnt);
  cout << cnt << "\n";
  for (int i = 0; i < 26; i++) {
    while (!a[1][i].empty() && !a[0][i].empty()) {
      cout << a[0][i].front() + 1 << " " << a[1][i].front() + 1 << "\n";
      a[0][i].pop();
      a[1][i].pop();
    }
    while (!a[1][i].empty() && !q[0].empty()) {
      cout << q[0].front() + 1 << " " << a[1][i].front() + 1 << "\n";
      q[0].pop();
      a[1][i].pop();
    }
    while (!a[0][i].empty() && !q[1].empty()) {
      cout << a[0][i].front() + 1 << " " << q[1].front() + 1 << "\n";
      a[0][i].pop();
      q[1].pop();
    }
  }
  while (!q[0].empty() && !q[1].empty()) {
    cout << q[0].front() + 1 << " " << q[1].front() + 1 << "\n";
    q[0].pop();
    q[1].pop();
  }
  return 0;
}
