#include <bits/stdc++.h>
using namespace std;
const int N = 3e4 + 2, K = 20;
const int mod = 1e9 + 7;
vector<int> lf[27];
vector<int> rf[27];
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    if (a[i] != '?') {
      lf[a[i] - 'a'].push_back(i + 1);
    } else {
      lf[26].push_back(i + 1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] != '?') {
      rf[b[i] - 'a'].push_back(i + 1);
    } else {
      rf[26].push_back(i + 1);
    }
  }
  vector<pair<int, int> > pr;
  for (int i = 0; i < 26; i++) {
    while (lf[i].size() && rf[i].size()) {
      pr.push_back(make_pair(lf[i].back(), rf[i].back()));
      lf[i].pop_back();
      rf[i].pop_back();
    }
  }
  for (int i = 0; i < 26; i++) {
    if (!lf[26].size()) break;
    while (lf[26].size() && rf[i].size()) {
      pr.push_back(make_pair(lf[26].back(), rf[i].back()));
      lf[26].pop_back();
      rf[i].pop_back();
    }
  }
  for (int i = 0; i < 26; i++) {
    if (!rf[26].size()) break;
    while (rf[26].size() && lf[i].size()) {
      pr.push_back(make_pair(lf[i].back(), rf[26].back()));
      rf[26].pop_back();
      lf[i].pop_back();
    }
  }
  while (rf[26].size() && lf[26].size()) {
    pr.push_back(make_pair(lf[26].back(), rf[26].back()));
    lf[26].pop_back();
    rf[26].pop_back();
  }
  cout << pr.size() << endl;
  for (auto x : pr) {
    printf("%d %d\n", x.first, x.second);
  }
  return 0;
}
