#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string left;
  string right;
  cin >> left >> right;
  vector<int> v1[27];
  vector<int> v2[27];
  for (int i = 0; i < n; i++) {
    if (left[i] == '?')
      v1[26].push_back(i + 1);
    else
      v1[left[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    if (right[i] == '?')
      v2[26].push_back(i + 1);
    else
      v2[right[i] - 'a'].push_back(i + 1);
  }
  vector<pair<int, int> > ans;
  for (int i = 0; i < 26; i++) {
    while (!v1[i].empty() && !v2[i].empty()) {
      ans.push_back({v1[i][v1[i].size() - 1], v2[i][v2[i].size() - 1]});
      v1[i].pop_back();
      v2[i].pop_back();
    }
  }
  for (int i = 0; i < 27; i++) {
    while (!v1[26].empty() && !v2[i].empty()) {
      ans.push_back({v1[26][v1[26].size() - 1], v2[i][v2[i].size() - 1]});
      v1[26].pop_back();
      v2[i].pop_back();
    }
  }
  for (int i = 0; i < 27; i++) {
    while (!v1[i].empty() && !v2[26].empty()) {
      ans.push_back({v1[i][v1[i].size() - 1], v2[26][v2[26].size() - 1]});
      v1[i].pop_back();
      v2[26].pop_back();
    }
  }
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.first << " " << i.second << endl;
  }
  return 0;
}
