#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string l, r;
  cin >> l >> r;
  vector<vector<int>> mp1(27);
  vector<vector<int>> mp2(27);
  vector<long long> qs;
  vector<long long> qs2;
  for (long long i = 0; i < n; i++) {
    if (l[i] == '?') {
      qs.push_back(i);
    } else {
      mp1[l[i] - 'a'].push_back(i);
    }
    if (r[i] == '?') {
      qs2.push_back(i);
    } else {
      mp2[r[i] - 'a'].push_back(i);
    }
  }
  long long ans = 0;
  vector<pair<long long, long long>> v;
  for (char x = 0; x <= 25; x++) {
    while (mp2[x].size() > 0 && mp1[x].size() > 0) {
      v.push_back(
          make_pair(mp1[x][mp1[x].size() - 1], mp2[x][mp2[x].size() - 1]));
      mp1[x].pop_back();
      mp2[x].pop_back();
    }
    while (mp2[x].size() > 0 && qs.size() > 0) {
      v.push_back(make_pair(qs[qs.size() - 1], mp2[x][mp2[x].size() - 1]));
      qs.pop_back();
      mp2[x].pop_back();
    }
    while (mp1[x].size() > 0 && qs2.size() > 0) {
      v.push_back(make_pair(mp1[x][mp1[x].size() - 1], qs2[qs2.size() - 1]));
      mp1[x].pop_back();
      qs2.pop_back();
    }
  }
  while (qs.size() > 0 && qs2.size() > 0) {
    v.push_back(make_pair(qs[qs.size() - 1], qs2[qs2.size() - 1]));
    qs.pop_back();
    qs2.pop_back();
  }
  cout << v.size() << "\n";
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i].first + 1 << " " << v[i].second + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
