#include <bits/stdc++.h>
using namespace std;
struct save {
  vector<int> l;
  vector<int> r;
};
int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  vector<save> check(26);
  vector<pair<int, int>> ans;
  save qm;
  for (int i = 0; i < n; i++) {
    if (s2[i] == '?') {
      qm.r.push_back(i);
    } else {
      if (check[s2[i] - 'a'].l.size() > 0) {
        ans.push_back(pair<int, int>(check[s2[i] - 'a'].l.back(), i));
        check[s2[i] - 'a'].l.pop_back();
      } else
        check[s2[i] - 'a'].r.push_back(i);
    }
    if (s1[i] == '?') {
      qm.l.push_back(i);
    } else {
      if (check[s1[i] - 'a'].r.size() > 0) {
        ans.push_back(pair<int, int>(i, check[s1[i] - 'a'].r.back()));
        check[s1[i] - 'a'].r.pop_back();
      } else
        check[s1[i] - 'a'].l.push_back(i);
    }
  }
  for (int i = 0; i < 26; i++) {
    if (check[i].l.size() > 0) {
      int size = check[i].l.size();
      for (int j = 0; j < size && qm.r.size() > 0; j++) {
        ans.push_back(pair<int, int>(check[i].l.back(), qm.r.back()));
        qm.r.pop_back();
        check[i].l.pop_back();
      }
    }
    if (check[i].r.size() > 0) {
      int size = check[i].r.size();
      for (int j = 0; j < size && qm.l.size() > 0; j++) {
        ans.push_back(pair<int, int>(qm.l.back(), check[i].r.back()));
        qm.l.pop_back();
        check[i].r.pop_back();
      }
    }
  }
  for (int i = 0; i < qm.l.size(); i++)
    ans.push_back(pair<int, int>(qm.l[i], qm.r[i]));
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
  return 0;
}
