#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238L;
void init() {
  cin.tie(0);
  cin.sync_with_stdio(0);
}
int main() {
  init();
  int n;
  cin >> n;
  string l, r;
  cin >> l >> r;
  vector<int> left[26];
  vector<int> right[26];
  vector<int> leftQ;
  vector<int> rightQ;
  for (int i = 0; i < n; i++) {
    if (l[i] != '?')
      left[l[i] - 'a'].push_back(i + 1);
    else
      leftQ.push_back(i + 1);
    if (r[i] != '?')
      right[r[i] - 'a'].push_back(i + 1);
    else
      rightQ.push_back(i + 1);
  }
  vector<pair<int, int> > pairs;
  int ileft = 0, iright = 0;
  for (int i = 0; i < 26; i++) {
    int mn = min(left[i].size(), right[i].size());
    for (int j = 0; j < mn; j++) {
      pairs.push_back(make_pair(left[i][j], right[i][j]));
    }
    int j = mn;
    while (j < left[i].size() && iright < rightQ.size())
      pairs.push_back(make_pair(left[i][j++], rightQ[iright++]));
    j = mn;
    while (j < right[i].size() && ileft < leftQ.size())
      pairs.push_back(make_pair(leftQ[ileft++], right[i][j++]));
  }
  while (ileft < leftQ.size() && iright < rightQ.size())
    pairs.push_back(make_pair(leftQ[ileft++], rightQ[iright++]));
  cout << pairs.size() << '\n';
  for (auto p : pairs) cout << p.first << " " << p.second << '\n';
}
