#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const double PI = acos(-1);
const double ERR = 1e-10;
char a[maxn], b[maxn];
int cnta[maxn], cntb[maxn];
int quea, queb;
vector<int> lia[30], lib[30];
vector<pair<int, int> > ans;
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] == '?') {
      quea++;
      lia[26].push_back(i);
    }
    if (b[i] == '?') {
      queb++;
      lib[26].push_back(i);
    }
    if (a[i] != '?') {
      cnta[a[i] - 'a']++;
      lia[a[i] - 'a'].push_back(i);
    }
    if (b[i] != '?') {
      cntb[b[i] - 'a']++;
      lib[b[i] - 'a'].push_back(i);
    }
  }
  int flaga = 0, flagb = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < min(lia[i].size(), lib[i].size()); j++) {
      ans.push_back(make_pair(lia[i][j], lib[i][j]));
    }
    for (int j = min(lia[i].size(), lib[i].size());
         j < max(lia[i].size(), lib[i].size()); j++) {
      if (lia[i].size() > lib[i].size() && flagb < lib[26].size()) {
        ans.push_back(make_pair(lia[i][j], lib[26][flagb]));
        flagb++;
      } else if (lia[i].size() < lib[i].size() && flaga < lia[26].size()) {
        ans.push_back(make_pair(lia[26][flaga], lib[i][j]));
        flaga++;
      }
    }
  }
  while (flaga < lia[26].size() && flagb < lib[26].size()) {
    ans.push_back(make_pair(lia[26][flaga], lib[26][flagb]));
    flaga++, flagb++;
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
