#include <bits/stdc++.h>
using namespace std;
stack<int> a[27];
stack<int> b[27];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  string f, s;
  cin >> f >> s;
  for (int i = 0; i < f.size(); ++i) {
    if (f[i] == '?') {
      a[26].push(i + 1);
    } else {
      a[(int)(f[i] - 'a')].push(i + 1);
    }
  }
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '?') {
      b[26].push(i + 1);
    } else {
      b[(int)(s[i] - 'a')].push(i + 1);
    }
  }
  int ans = 0;
  vector<pair<int, int> > anss;
  for (int i = 0; i < 27; ++i) {
    while ((a[i].size() != 0 && b[i].size() != 0) ||
           (a[i].size() != 0 && b[26].size() != 0) ||
           (a[26].size() != 0 && b[i].size() != 0)) {
      if (a[i].size() != 0 && b[i].size() != 0) {
        int c1, c2;
        c1 = a[i].top();
        c2 = b[i].top();
        ans++;
        a[i].pop();
        b[i].pop();
        anss.push_back({c1, c2});
      } else if (a[i].size() != 0 && b[i].size() == 0) {
        if (b[26].size() != 0) {
          int c1, c2;
          c1 = a[i].top();
          c2 = b[26].top();
          ans++;
          a[i].pop();
          b[26].pop();
          anss.push_back({c1, c2});
        }
      } else if (a[i].size() == 0 && b[i].size() != 0) {
        if (a[26].size() != 0) {
          int c1, c2;
          c1 = a[26].top();
          c2 = b[i].top();
          ans++;
          a[26].pop();
          b[i].pop();
          anss.push_back({c1, c2});
        }
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < anss.size(); ++i) {
    cout << anss[i].first << " " << anss[i].second << endl;
  }
  return 0;
}
