#include <bits/stdc++.h>
using namespace std;
int n;
char s[150005], t[150005];
queue<int> p[27], q[27];
vector<pair<int, int> > ans;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < 27; i++) {
      while (q[i].size()) q[i].pop();
      while (p[i].size()) p[i].pop();
    }
    ans.clear();
    scanf("%s %s", s + 1, t + 1);
    for (int i = 1; i <= n; i++) {
      p[s[i] == '?' ? 26 : s[i] - 'a'].push(i);
      q[t[i] == '?' ? 26 : t[i] - 'a'].push(i);
    }
    for (int i = 0; i < 27; i++) {
      while (p[i].size() && q[i].size()) {
        int u = p[i].front();
        p[i].pop();
        int v = q[i].front();
        q[i].pop();
        ans.push_back(make_pair(u, v));
      }
      while (p[i].size() && q[26].size()) {
        int u = p[i].front();
        p[i].pop();
        int v = q[26].front();
        q[26].pop();
        ans.push_back(make_pair(u, v));
      }
      while (p[26].size() && q[i].size()) {
        int u = p[26].front();
        p[26].pop();
        int v = q[i].front();
        q[i].pop();
        ans.push_back(make_pair(u, v));
      }
    }
    printf("%d\n", ans.size());
    for (auto v : ans) {
      printf("%d %d\n", v.first, v.second);
    }
  }
  return 0;
}
