#include <bits/stdc++.h>
using namespace std;
priority_queue<int> l[26], r[26], ql, qr;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    if (s[i] == '?')
      ql.push(i);
    else
      l[s[i] - 'a'].push(i);
    if (t[i] == '?')
      qr.push(i);
    else
      r[t[i] - 'a'].push(i);
  }
  vector<pair<int, int> > ans;
  for (int i = 0, ThxDem = 26; i < ThxDem; ++i) {
    while (((int)(l[i]).size()) && ((int)(r[i]).size())) {
      ans.push_back({l[i].top(), r[i].top()});
      l[i].pop();
      r[i].pop();
    }
  }
  for (int i = 0, ThxDem = 26; i < ThxDem; ++i) {
    while (((int)(r[i]).size()) && ((int)(ql).size())) {
      ans.push_back({ql.top(), r[i].top()});
      ql.pop();
      r[i].pop();
    }
  }
  for (int i = 0, ThxDem = 26; i < ThxDem; ++i) {
    while (((int)(l[i]).size()) && ((int)(qr).size())) {
      ans.push_back({l[i].top(), qr.top()});
      qr.pop();
      l[i].pop();
    }
  }
  while (((int)(ql).size()) && ((int)(qr).size())) {
    ans.push_back({ql.top(), qr.top()});
    ql.pop();
    qr.pop();
  }
  cout << ((int)(ans).size()) << "\n";
  for (auto x : ans) cout << x.first + 1 << " " << x.second + 1 << "\n";
}
