#include <bits/stdc++.h>
using namespace std;
template <typename dataType>
dataType nthGrayCode(dataType n) {
  return (n ^ (n >> 1));
}
template <typename dataType>
void generateAllSubset(vector<dataType> &data) {
  int i, j, n;
  n = data.size();
  for (i = 0; i < (1 << n); i++) {
    for (j = 0; j < n; j++) {
      if (i & (1 << j)) {
        cout << data[j] << " ";
      }
    }
    cout << "\n";
  }
}
queue<int> Left[255], Right[255];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i, l, r;
  string strL, strR;
  char ch;
  vector<pair<int, int> > ans;
  cin >> n >> strL >> strR;
  for (i = 0; i < n; i++) {
    ch = strL[i];
    Left[ch].push(i);
    ch = strR[i];
    Right[ch].push(i);
  }
  for (ch = 'a'; ch <= 'z'; ch++) {
    while (true) {
      if (Left[ch].empty() || Right[ch].empty()) {
        break;
      }
      l = Left[ch].front();
      r = Right[ch].front();
      Left[ch].pop();
      Right[ch].pop();
      ans.push_back(make_pair(l, r));
    }
  }
  for (ch = 'a'; ch <= 'z'; ch++) {
    if (Left['?'].empty()) {
      break;
    }
    if (Right[ch].empty()) {
      continue;
    }
    while (true) {
      if (Left['?'].empty() || Right[ch].empty()) {
        break;
      }
      l = Left['?'].front();
      r = Right[ch].front();
      Left['?'].pop();
      Right[ch].pop();
      ans.push_back(make_pair(l, r));
    }
  }
  for (ch = 'a'; ch <= 'z'; ch++) {
    if (Right['?'].empty()) {
      break;
    }
    if (Left[ch].empty()) {
      continue;
    }
    while (true) {
      if (Right['?'].empty() || Left[ch].empty()) {
        break;
      }
      l = Left[ch].front();
      r = Right['?'].front();
      Left[ch].pop();
      Right['?'].pop();
      ans.push_back(make_pair(l, r));
    }
  }
  while (true) {
    if (Left['?'].empty() || Right['?'].empty()) {
      break;
    }
    l = Left['?'].front();
    r = Right['?'].front();
    Left['?'].pop();
    Right['?'].pop();
    ans.push_back(make_pair(l, r));
  }
  cout << ans.size() << "\n";
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
  }
  return 0;
}
