#include <bits/stdc++.h>
using namespace std;
map<char, vector<int> > A, B;
int main(int argc, char** argv) {
  int N;
  cin >> N;
  string a, b;
  cin >> a >> b;
  int idx = 1;
  for (const auto& c : a) {
    if (!A.count(c)) A[c] = vector<int>();
    A[c].push_back(idx);
    idx++;
  }
  idx = 1;
  for (const auto& c : b) {
    if (!B.count(c)) B[c] = vector<int>();
    B[c].push_back(idx);
    idx++;
  }
  vector<pair<int, int> > res;
  for (char i = 'a'; i <= 'z'; ++i) {
    if (A.count(i) && B.count(i)) {
      auto& aa = A[i];
      auto& bb = B[i];
      while (aa.size() > 0 && bb.size() > 0) {
        res.push_back(make_pair(aa.back(), bb.back()));
        aa.pop_back();
        bb.pop_back();
      }
    }
  }
  if (A.count('?')) {
    auto& aa = A['?'];
    for (char i = 'a'; i <= 'z'; ++i) {
      if (B.count(i)) {
        auto& bb = B[i];
        while (bb.size() > 0 && aa.size() > 0) {
          res.push_back(make_pair(aa.back(), bb.back()));
          aa.pop_back();
          bb.pop_back();
        }
      }
    }
  }
  if (B.count('?')) {
    auto& bb = B['?'];
    for (char i = 'a'; i <= 'z'; ++i) {
      if (A.count(i)) {
        auto& aa = A[i];
        while (aa.size() > 0 && bb.size() > 0) {
          res.push_back(make_pair(aa.back(), bb.back()));
          bb.pop_back();
          aa.pop_back();
        }
      }
    }
  }
  if (A.count('?') && B.count('?')) {
    int z = min(A['?'].size(), B['?'].size());
    for (int i = (0); i < (z); ++i) {
      res.push_back(make_pair(A['?'].back(), B['?'].back()));
      A['?'].pop_back();
      B['?'].pop_back();
    }
  }
  printf("%d\n", (int)res.size());
  for (const auto& pr : res) {
    printf("%d %d\n", pr.first, pr.second);
  }
  return 0;
}
