#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> k;
  vector<int> h;
  vector<pair<int, int> > ans;
  vector<int> vl[27];
  vector<int> vr[27];
  int n;
  cin >> n;
  string l, r;
  cin >> l;
  cin >> r;
  for (int i = 0; i < n; i++) {
    if (l[i] != '?') {
      vl[l[i] - 'a'].push_back(i);
    } else if (l[i] == '?')
      vl[26].push_back(i);
    if (r[i] != '?') {
      vr[r[i] - 'a'].push_back(i);
    } else if (r[i] == '?')
      vr[26].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < min(vl[i].size(), vr[i].size()); j++) {
      ans.push_back(make_pair(vl[i][j], vr[i][j]));
      l[vl[i][j]] = 'A';
      r[vr[i][j]] = 'A';
    }
  }
  int p;
  if (vl[26].size() != 0) {
    p = 0;
    for (int i = 0; i < n; i++) {
      if (r[i] != 'A' && r[i] != '?' && p < vl[26].size()) {
        ans.push_back(make_pair(vl[26][p], i));
        l[vl[26][p]] = 'A';
        r[i] = 'A';
        p++;
      }
    }
  }
  if (vr[26].size() != 0) {
    p = 0;
    for (int i = 0; i < n; i++) {
      if (l[i] != 'A' && l[i] != '?' && p < vr[26].size()) {
        ans.push_back(make_pair(i, vr[26][p]));
        r[vr[26][p]] = 'A';
        l[i] = 'A';
        p++;
      }
    }
    for (int i = 0; i < n; i++) {
      if (l[i] == '?') {
        k.push_back(i);
      }
      if (r[i] == '?') {
        h.push_back(i);
      }
    }
  }
  for (int i = 0; i < min(k.size(), h.size()); i++) {
    ans.push_back(make_pair(k[i], h[i]));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
}
