#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
char s[200005];
vector<long long> cnt[3][202];
vector<pair<long long, long long> > res;
int main() {
  long long i, j;
  scanf("%lld", &n);
  scanf("%s", &s);
  for (i = 0; i <= n - 1; i++) {
    cnt[1][s[i]].push_back(i + 1);
  }
  scanf("%s", &s);
  for (i = 0; i <= n - 1; i++) {
    cnt[2][s[i]].push_back(i + 1);
  }
  for (i = 'a'; i <= 'z'; i++) {
    while (cnt[1][i].size() && cnt[2][i].size()) {
      res.push_back(make_pair(cnt[1][i].back(), cnt[2][i].back()));
      cnt[1][i].pop_back(), cnt[2][i].pop_back();
    }
  }
  for (i = 'a'; i <= 'z'; i++) {
    while (cnt[2][i].size() && cnt[1]['?'].size()) {
      res.push_back(make_pair(cnt[1]['?'].back(), cnt[2][i].back()));
      cnt[1]['?'].pop_back(), cnt[2][i].pop_back();
    }
  }
  for (i = 'a'; i <= 'z'; i++) {
    while (cnt[1][i].size() && cnt[2]['?'].size()) {
      res.push_back(make_pair(cnt[1][i].back(), cnt[2]['?'].back()));
      cnt[2]['?'].pop_back(), cnt[1][i].pop_back();
    }
  }
  while (cnt[1]['?'].size() && cnt[2]['?'].size()) {
    res.push_back(make_pair(cnt[1]['?'].back(), cnt[2]['?'].back()));
    cnt[2]['?'].pop_back(), cnt[1]['?'].pop_back();
  }
  long long d = res.size();
  printf("%lld\n", d);
  for (i = 0; i <= d - 1; i++) {
    printf("%lld %lld\n", res[i].first, res[i].second);
  }
  return 0;
}
