#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  map<char, vector<int>> ma, mb;
  for (int i = 0; i < n; i++) {
    ma[a[i]].push_back(i + 1);
    mb[b[i]].push_back(i + 1);
  }
  vector<pair<int, int>> ans;
  int l1 = 0, l2 = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    int j = 0;
    while (j < ma[i].size() && j < mb[i].size()) {
      ans.push_back({ma[i][j], mb[i][j]});
      j++;
    }
    while (j < ma[i].size() && l2 < mb['?'].size()) {
      ans.push_back({ma[i][j], mb['?'][l2]});
      j++;
      l2++;
    }
    while (j < mb[i].size() && l1 < ma['?'].size()) {
      ans.push_back({ma['?'][l1], mb[i][j]});
      j++;
      l1++;
    }
  }
  while (l1 < ma['?'].size() && l2 < mb['?'].size()) {
    ans.push_back({ma['?'][l1], mb['?'][l2]});
    l1++;
    l2++;
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
}
