#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150005;
const int INF = 0x3f3f3f3f;
char l[MAXN], r[MAXN];
int top = 0;
stack<int> lc[100], rc[100];
struct Ans {
  int l, r;
} ans[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s%s", l, r);
  for (int i = 0; l[i] != '\0'; i++) {
    if (l[i] == '?')
      lc[66].push(i);
    else
      lc[l[i] - 'a'].push(i);
    if (r[i] == '?')
      rc[66].push(i);
    else
      rc[r[i] - 'a'].push(i);
  }
  for (int i = 0; i < 26; i++) {
    while (lc[i].size() && rc[i].size()) {
      ans[top].l = lc[i].top();
      ans[top++].r = rc[i].top();
      lc[i].pop();
      rc[i].pop();
    }
    while (lc[i].size() && rc[66].size()) {
      ans[top].l = lc[i].top();
      ans[top++].r = rc[66].top();
      lc[i].pop();
      rc[66].pop();
    }
    while (lc[66].size() && rc[i].size()) {
      ans[top].l = lc[66].top();
      ans[top++].r = rc[i].top();
      lc[66].pop();
      rc[i].pop();
    }
  }
  while (lc[66].size() && rc[66].size()) {
    ans[top].l = lc[66].top();
    ans[top++].r = rc[66].top();
    lc[66].pop();
    rc[66].pop();
  }
  printf("%d\n", top);
  for (int i = 0; i < top; i++) {
    printf("%d %d\n", ans[i].l + 1, ans[i].r + 1);
  }
  return 0;
}
