#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  string left, right;
  unordered_map<char, vector<int>> kol_left, kol_right;
  cin >> left >> right;
  for (int i = 0; i < n; i++) {
    char c = left[i];
    kol_left[c].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    char c = right[i];
    kol_right[c].push_back(i);
  }
  vector<pair<int, int>> ans;
  for (auto p : kol_left) {
    if (p.first == '?')
      continue;
    else {
      while (!kol_left[p.first].empty() && !kol_right[p.first].empty()) {
        auto left_back = kol_left[p.first].back();
        kol_left[p.first].pop_back();
        auto right_back = kol_right[p.first].back();
        kol_right[p.first].pop_back();
        ans.push_back(make_pair(left_back, right_back));
      }
    }
  }
  for (auto p : kol_right) {
    if (p.first == '?')
      continue;
    else {
      while (!kol_right[p.first].empty() && !kol_left['?'].empty()) {
        auto left_back = kol_left['?'].back();
        kol_left['?'].pop_back();
        auto right_back = kol_right[p.first].back();
        kol_right[p.first].pop_back();
        ans.push_back(make_pair(left_back, right_back));
      }
    }
  }
  for (auto p : kol_left) {
    if (p.first == '?')
      continue;
    else {
      while (!kol_left[p.first].empty() && !kol_right['?'].empty()) {
        auto left_back = kol_left[p.first].back();
        kol_left[p.first].pop_back();
        auto right_back = kol_right['?'].back();
        kol_right['?'].pop_back();
        ans.push_back(make_pair(left_back, right_back));
      }
    }
  }
  while (!kol_left['?'].empty() && !kol_right['?'].empty()) {
    auto left_back = kol_left['?'].back();
    kol_left['?'].pop_back();
    auto right_back = kol_right['?'].back();
    kol_right['?'].pop_back();
    ans.push_back(make_pair(left_back, right_back));
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i.first + 1 << " " << i.second + 1 << endl;
  return 0;
}
