#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string l, r;
  cin >> n >> l >> r;
  vector<vector<int>> tmp(27);
  for (int i = 0; i < n; i++) {
    if (r[i] == '?') {
      tmp[26].push_back(i);
    } else {
      tmp[r[i] - 'a'].push_back(i);
    }
  }
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    if (l[i] != '?') {
      if (tmp[l[i] - 'a'].size()) {
        ans.push_back({i + 1, tmp[l[i] - 'a'][0] + 1});
        tmp[l[i] - 'a'].erase(tmp[l[i] - 'a'].begin());
      } else if (tmp[26].size()) {
        ans.push_back({i + 1, tmp[26][0] + 1});
        tmp[26].erase(tmp[26].begin());
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (l[i] == '?') {
      for (int j = 0; j <= 26; j++) {
        if (tmp[j].size()) {
          ans.push_back({i + 1, tmp[j][0] + 1});
          tmp[j].erase(tmp[j].begin());
          break;
        }
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
