#include <bits/stdc++.h>
using namespace std;
vector<long long> righ[200];
vector<long long> e1;
vector<long long> e2;
vector<pair<long long, long long> > p;
int main() {
  ios::sync_with_stdio(0);
  long long n;
  string r, l;
  cin >> n >> r >> l;
  for (int i = 0; i < n; i++) {
    if (r[i] == '?')
      e1.push_back(i + 1);
    else
      righ[r[i]].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    if (l[i] == '?') {
      e2.push_back(i + 1);
      continue;
    }
    if (righ[l[i]].size() > 0) {
      p.push_back(make_pair(righ[l[i]].back(), i + 1));
      righ[l[i]].pop_back();
    } else {
      if (!e1.empty()) {
        p.push_back(make_pair(e1.back(), i + 1));
        e1.pop_back();
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!righ[r[i]].empty()) {
      if (e2.empty())
        break;
      else {
        p.push_back(make_pair(righ[r[i]].back(), e2.back()));
        e2.pop_back();
        righ[r[i]].pop_back();
      }
    }
  }
  while (!e1.empty() && !e2.empty()) {
    p.push_back(make_pair(e1.back(), e2.back()));
    e1.pop_back();
    e2.pop_back();
  }
  cout << p.size() << endl;
  for (int i = 0; i < p.size(); i++) {
    cout << p[i].first << " " << p[i].second << endl;
  }
  return 0;
}
