#include <bits/stdc++.h>
using namespace std;
int n;
map<char, vector<int>> l;
map<char, vector<int>> r;
vector<pair<int, int>> ans;
int main() {
  scanf("%d", &n);
  getchar();
  for (int i = 0; i < n; i++) {
    char ch = getchar();
    l[ch].push_back(i);
  }
  getchar();
  for (int i = 0; i < n; i++) {
    char ch = getchar();
    r[ch].push_back(i);
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    while (l[ch].size() > 0 && r[ch].size() > 0) {
      ans.push_back(make_pair(l[ch].back(), r[ch].back()));
      l[ch].pop_back();
      r[ch].pop_back();
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    while (l['?'].size() > 0 && r[ch].size() > 0) {
      ans.push_back(make_pair(l['?'].back(), r[ch].back()));
      l['?'].pop_back();
      r[ch].pop_back();
    }
  }
  for (char ch = 'a'; ch <= 'z'; ch++) {
    while (l[ch].size() > 0 && r['?'].size() > 0) {
      ans.push_back(make_pair(l[ch].back(), r['?'].back()));
      l[ch].pop_back();
      r['?'].pop_back();
    }
  }
  while (l['?'].size() > 0 && r['?'].size() > 0) {
    ans.push_back(make_pair(l['?'].back(), r['?'].back()));
    l['?'].pop_back();
    r['?'].pop_back();
  }
  cout << ans.size() << '\n';
  for (auto &p : ans) {
    cout << p.first + 1 << ' ' << p.second + 1 << '\n';
  }
}
