#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
using LL = int64_t;
vector<int> E[30][3];
vector<pair<int, int>> ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  string l, r;
  cin >> n >> l >> r;
  for (int i = 0; i < n; i++) {
    if (l[i] == '?') E[26][0].push_back(i + 1);
    if (r[i] == '?') E[26][1].push_back(i + 1);
    if (l[i] >= 'a' && l[i] <= 'z') E[l[i] - 'a'][0].push_back(i + 1);
    if (r[i] >= 'a' && r[i] <= 'z') E[r[i] - 'a'][1].push_back(i + 1);
  }
  for (int i = 0; i <= 26; i++) {
    while (E[i][0].size() > 0 && E[i][1].size() > 0) {
      ans.push_back({E[i][0].back(), E[i][1].back()});
      E[i][0].pop_back();
      E[i][1].pop_back();
    }
    while (E[i][0].size() > 0 && E[26][1].size() > 0) {
      ans.push_back({E[i][0].back(), E[26][1].back()});
      E[i][0].pop_back();
      E[26][1].pop_back();
    }
    while (E[i][1].size() > 0 && E[26][0].size() > 0) {
      ans.push_back({E[26][0].back(), E[i][1].back()});
      E[i][1].pop_back();
      E[26][0].pop_back();
    }
  }
  cout << ans.size() << '\n';
  for (auto it : ans) cout << it.first << ' ' << it.second << '\n';
  return 0;
}
