#include <bits/stdc++.h>
using namespace std;
const int maxn = 150007;
int n;
char a[maxn], b[maxn];
int main() {
  while (cin >> n) {
    stack<int> a1[30], b1[30];
    vector<pair<int, int> > ans;
    scanf("%s", a);
    scanf("%s", b);
    for (int i = 0; i < n; i++) {
      if (a[i] == '?') a1[27].push(i + 1);
      if (b[i] == '?') b1[27].push(i + 1);
      if (a[i] >= 'a' && a[i] <= 'z') a1[a[i] - 'a'].push(i + 1);
      if (b[i] >= 'a' && b[i] <= 'z') b1[b[i] - 'a'].push(i + 1);
    }
    for (int i = 0; i < 26; i++) {
      while (!a1[i].empty() && !b1[i].empty()) {
        ans.push_back(make_pair(a1[i].top(), b1[i].top()));
        a1[i].pop();
        b1[i].pop();
      }
      while (!a1[i].empty() && !b1[27].empty()) {
        ans.push_back(make_pair(a1[i].top(), b1[27].top()));
        a1[i].pop();
        b1[27].pop();
      }
      while (!b1[i].empty() && !a1[27].empty()) {
        ans.push_back(make_pair(a1[27].top(), b1[i].top()));
        a1[27].pop();
        b1[i].pop();
      }
    }
    while (!a1[27].empty() && !b1[27].empty()) {
      ans.push_back(make_pair(a1[27].top(), b1[27].top()));
      a1[27].pop();
      b1[27].pop();
    }
    printf("%d\n", ans.size());
    while (ans.size()) {
      printf("%d %d\n", ans.back().first, ans.back().second);
      ans.pop_back();
    }
  }
}
