#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
char l[MAXN];
char r[MAXN];
vector<int> lch2inds[200];
vector<int> rch2inds[200];
vector<pair<int, int> > ansP;
int main() {
  int n;
  scanf("%d", &n);
  scanf(" %s", l + 1);
  scanf(" %s", r + 1);
  for (int i = 1; i <= n; ++i) {
    lch2inds[l[i]].push_back(i);
    rch2inds[r[i]].push_back(i);
  }
  for (char b = 'a'; b <= 'z'; ++b) {
    int match = min(lch2inds[b].size(), rch2inds[b].size());
    const int popCnt = match;
    for (int k = 1; k <= popCnt; ++k) {
      ansP.push_back({lch2inds[b].back(), rch2inds[b].back()});
      lch2inds[b].pop_back();
      rch2inds[b].pop_back();
    }
  }
  {
    for (char b = 'a'; b <= 'z'; ++b) {
      int match = min(lch2inds[b].size(), rch2inds['?'].size());
      const int popCnt = match;
      for (int k = 1; k <= popCnt; ++k) {
        ansP.push_back({lch2inds[b].back(), rch2inds['?'].back()});
        lch2inds[b].pop_back();
        rch2inds['?'].pop_back();
      }
    }
  }
  for (char b = 'a'; (b >= 'a' && b <= 'z') || b == '?'; ++b) {
    int match = min(lch2inds['?'].size(), rch2inds[b].size());
    const int popCnt = match;
    for (int k = 1; k <= popCnt; ++k) {
      ansP.push_back({lch2inds['?'].back(), rch2inds[b].back()});
      lch2inds['?'].pop_back();
      rch2inds[b].pop_back();
    }
    if (b == 'z') {
      b = '?' - 1;
    }
  }
  printf("%d\n", int(ansP.size()));
  for (auto pa : ansP) {
    printf("%d %d\n", pa.first, pa.second);
  }
}
