#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> left[27], right[27];
  vector<pair<int, int> > ans;
  string l, r;
  cin >> l >> r;
  for (int i = 0; i < n; i++) {
    char c = l[i];
    if (c == '?')
      left[26].push_back(i + 1);
    else
      left[c - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    char c = r[i];
    if (c == '?')
      right[26].push_back(i + 1);
    else
      right[c - 'a'].push_back(i + 1);
  }
  for (int i = 0; i <= 26; i++) {
    int len = min(left[i].size(), right[i].size()), j = 0;
    for (j = 0; j < len; j++) {
      ans.push_back(make_pair(left[i][j], right[i][j]));
    }
    for (int k = j; k < left[i].size() && right[26].size(); k++) {
      ans.push_back(make_pair(left[i][k], right[26].back()));
      right[26].pop_back();
    }
    for (int k = j; k < right[i].size() && left[26].size(); k++) {
      ans.push_back(make_pair(left[26].back(), right[i][k]));
      left[26].pop_back();
    }
  }
  cout << ans.size() << endl;
  for (auto &i : ans) {
    cout << i.first << ' ' << i.second << endl;
  }
  return 0;
}
