#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, countf = 0, countf1 = 0;
  cin >> n;
  vector<long long> v1[27], v[27];
  string s, s1;
  cin >> s >> s1;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '?') {
      v[26].push_back(i + 1);
      countf++;
    } else
      v[s[i] - 'a'].push_back(i + 1);
  }
  for (long long i = 0; i < n; i++) {
    if (s1[i] == '?') {
      v1[26].push_back(i + 1);
      countf1++;
    } else
      v1[s1[i] - 'a'].push_back(i + 1);
  }
  long long count = 0, pairs;
  vector<long long> countpairs, countpairs1;
  for (long long i = 0; i < 26; i++) {
    while (!v[i].empty() && !v1[i].empty()) {
      countpairs.push_back(v[i].back());
      countpairs1.push_back(v1[i].back());
      v[i].pop_back();
      v1[i].pop_back();
    }
  }
  for (long long i = 0; i < 26; i++) {
    while (!v[i].empty() && !v1[26].empty()) {
      countpairs.push_back(v[i].back());
      countpairs1.push_back(v1[26].back());
      v[i].pop_back();
      v1[26].pop_back();
    }
    while (!v1[i].empty() && !v[26].empty()) {
      countpairs.push_back(v[26].back());
      countpairs1.push_back(v1[i].back());
      v[26].pop_back();
      v1[i].pop_back();
    }
  }
  while (!v[26].empty() && !v1[26].empty()) {
    countpairs.push_back(v[26].back());
    countpairs1.push_back(v1[26].back());
    v[26].pop_back();
    v1[26].pop_back();
  }
  cout << countpairs.size() << "\n";
  for (long long i = 0; i < countpairs.size(); i++) {
    cout << countpairs[i] << " " << countpairs1[i] << "\n";
  }
  return 0;
}
