#include <bits/stdc++.h>
using namespace std;
const int maxN = 27;
vector<int> s1[maxN];
vector<int> s2[maxN];
string s;
int n;
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++)
    isalpha(s[i]) ? s1[s[i] - 'a'].push_back(i) : s1[26].push_back(i);
  cin >> s;
  for (int i = 0; i < n; i++)
    isalpha(s[i]) ? s2[s[i] - 'a'].push_back(i) : s2[26].push_back(i);
  vector<pair<int, int>> ans;
  for (int i = 0; i < 26; i++) {
    while (s1[i].size() && s2[i].size()) {
      ans.emplace_back(s1[i].back(), s2[i].back());
      s1[i].pop_back();
      s2[i].pop_back();
    }
  }
  for (int i = 0; i < 26 && s1[26].size();) {
    if (s2[i].empty()) {
      i++;
      continue;
    }
    ans.emplace_back(s1[26].back(), s2[i].back());
    s1[26].pop_back();
    s2[i].pop_back();
  }
  for (int i = 0; i < 26 && s2[26].size();) {
    if (s1[i].empty()) {
      i++;
      continue;
    }
    ans.emplace_back(s1[i].back(), s2[26].back());
    s1[i].pop_back();
    s2[26].pop_back();
  }
  while (s1[26].size() && s2[26].size()) {
    ans.emplace_back(s1[26].back(), s2[26].back());
    s1[26].pop_back();
    s2[26].pop_back();
  }
  cout << ans.size() << endl;
  for (auto it : ans) cout << it.first + 1 << " " << it.second + 1 << endl;
  return 0;
}
