#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string l, r;
  cin >> l >> r;
  vector<stack<int>> l_array;
  vector<stack<int>> r_array;
  for (int i = 0; i < 27; i++) {
    stack<int> buf;
    l_array.push_back(buf);
    r_array.push_back(buf);
  }
  for (int i = 0; i < n; i++) {
    if (l[i] == '?') {
      l_array[26].push(i);
    } else {
      l_array[l[i] - 'a'].push(i);
    }
    if (r[i] == '?') {
      r_array[26].push(i);
    } else {
      r_array[r[i] - 'a'].push(i);
    }
  }
  vector<pair<int, int>> answer;
  for (int i = 0; i < 26; i++) {
    while (!l_array[i].empty() && !r_array[i].empty()) {
      answer.push_back(make_pair(l_array[i].top(), r_array[i].top()));
      l_array[i].pop();
      r_array[i].pop();
    }
    while (!l_array[i].empty() && !r_array[26].empty()) {
      answer.push_back(make_pair(l_array[i].top(), r_array[26].top()));
      l_array[i].pop();
      r_array[26].pop();
    }
    while (!r_array[i].empty() && !l_array[26].empty()) {
      answer.push_back(make_pair(l_array[26].top(), r_array[i].top()));
      l_array[26].pop();
      r_array[i].pop();
    }
  }
  while (!l_array[26].empty() && !r_array[26].empty()) {
    answer.push_back(make_pair(l_array[26].top(), r_array[26].top()));
    l_array[26].pop();
    r_array[26].pop();
  }
  int count = answer.size();
  cout << count << endl;
  for (int i = 0; i < count; i++) {
    cout << answer[i].first + 1 << " " << answer[i].second + 1 << endl;
  }
  return 0;
}
