#include <bits/stdc++.h>
using namespace std;
int n;
char s1[1000010], s2[1000010];
queue<int> p1[200], p2[200];
vector<pair<int, int>> r;
int main() {
  scanf("%d%s%s", &n, s1 + 1, s2 + 1);
  for (int i = (1); i <= (n); ++i) {
    p1[s1[i]].push(i);
    p2[s2[i]].push(i);
  }
  for (int i = ('a'); i <= ('z'); ++i) {
    while (!p1[i].empty() && !p2[i].empty()) {
      r.push_back({p1[i].front(), p2[i].front()});
      p1[i].pop();
      p2[i].pop();
    }
    while (!p1[i].empty() && !p2['?'].empty()) {
      r.push_back({p1[i].front(), p2['?'].front()});
      p1[i].pop();
      p2['?'].pop();
    }
    while (!p1['?'].empty() && !p2[i].empty()) {
      r.push_back({p1['?'].front(), p2[i].front()});
      p1['?'].pop();
      p2[i].pop();
    }
  }
  while (!p1['?'].empty() && !p2['?'].empty()) {
    r.push_back({p1['?'].front(), p2['?'].front()});
    p1['?'].pop();
    p2['?'].pop();
  }
  cout << r.size() << '\n';
  for (auto i : r) printf("%d %d\n", i.first, i.second);
}
