#include <bits/stdc++.h>
using namespace std;
vector<long long> l[200];
vector<long long> r[200];
vector<pair<long long, long long> > ans;
signed main() {
  long long n, l_q = 1, r_q = 1;
  char c;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> c;
    l[(long long)c].push_back(i);
  }
  for (long long i = 0; i < n; i++) {
    cin >> c;
    r[(long long)c].push_back(i);
  }
  for (long long i = 0; i < 200; i++) {
    if (i != (long long)'?') {
      if (l[i].size() != 0 && r[i].size() != 0) {
        for (long long j = 0; j < min(l[i].size(), r[i].size()); j++) {
          ans.push_back({l[i][j], r[i][j]});
        }
      }
      if (l[i].size() > r[i].size() && r[(long long)'?'].size()) {
        for (long long j = r[i].size();
             j < l[i].size() && r_q <= r[(long long)'?'].size(); j++, r_q++) {
          ans.push_back({l[i][j], r[(long long)'?'][r_q - 1]});
        }
      }
      if (r[i].size() > l[i].size() && l[(long long)'?'].size()) {
        for (long long j = l[i].size();
             j < r[i].size() && l_q <= l[(long long)'?'].size(); j++, l_q++) {
          ans.push_back({l[(long long)'?'][l_q - 1], r[i][j]});
        }
      }
    }
  }
  while (r_q <= r[(long long)'?'].size() && l_q <= l[(long long)'?'].size()) {
    ans.push_back({l[(long long)'?'][l_q - 1], r[(long long)'?'][r_q - 1]});
    r_q++;
    l_q++;
  }
  cout << ans.size() << "\n";
  for (auto i : ans) {
    cout << i.first + 1 << " " << i.second + 1 << "\n";
  }
  return 0;
}
