#include <bits/stdc++.h>
using namespace std;
vector<int> A[30], B[30];
vector<pair<int, int> > save;
int n;
int main() {
  cin >> n;
  char ch;
  int INDEX;
  int ans = 0;
  getchar();
  for (int i = 1; i <= n; i++) {
    scanf("%c", &ch);
    if (ch == '?') {
      A[0].push_back(i);
      continue;
    }
    A[ch - 'a' + 1].push_back(i);
  }
  getchar();
  for (int i = 1; i <= n; i++) {
    scanf("%c", &ch);
    if (ch == '?') {
      B[0].push_back(i);
      continue;
    }
    INDEX = ch - 'a' + 1;
    if (A[INDEX].size()) {
      ans++;
      save.push_back(pair<int, int>(A[INDEX].back(), i));
      A[INDEX].pop_back();
    } else
      B[INDEX].push_back(i);
  }
  for (int i = 1; i < 30; i++) {
    {
      if (A[0].empty()) break;
      while (!B[i].empty() && !A[0].empty()) {
        ans++;
        save.push_back(pair<int, int>(A[0].back(), B[i].back()));
        A[0].pop_back();
        B[i].pop_back();
      }
    }
  }
  for (int i = 1; i < 30; i++) {
    if (B[0].empty()) break;
    while (!B[0].empty() && !A[i].empty()) {
      ans++;
      save.push_back(pair<int, int>(A[i].back(), B[0].back()));
      A[i].pop_back();
      B[0].pop_back();
    }
  }
  while (!B[0].empty() && !A[0].empty()) {
    ans++;
    save.push_back(pair<int, int>(A[0].back(), B[0].back()));
    A[0].pop_back();
    B[0].pop_back();
  }
  cout << ans << endl;
  for (auto i : save) {
    printf("%d %d\n", i.first, i.second);
  }
}
