#include <bits/stdc++.h>
using namespace std;
string process(string s) {
  int cnt = 0;
  for (auto &x : s)
    if (x == '?') cnt++;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '?') {
      s.erase(i, 1);
      i--;
    }
  }
  int j = 0;
  while (j < cnt) {
    j++;
    s += "?";
  }
  return s;
}
int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  unordered_map<char, stack<int> > mp;
  for (int i = 0; i < n; i++) {
    mp[s1[i]].push(i + 1);
  }
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    char x = s2[i];
    if (x == '?') {
      continue;
    }
    if (!mp[x].empty()) {
      v.push_back({mp[x].top(), i + 1});
      mp[x].pop();
    } else {
      if (!mp['?'].empty()) {
        v.push_back({mp['?'].top(), i + 1});
        mp['?'].pop();
      }
    }
  }
  for (int i = 0; i < n; i++) {
    char x = s2[i];
    if (x != '?') {
      continue;
    }
    bool flag = 0;
    for (int j = 0; j < 26; j++) {
      if (!mp['a' + j].empty()) {
        v.push_back({mp['a' + j].top(), i + 1});
        mp['a' + j].pop();
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      if (!mp[x].empty()) {
        v.push_back({mp['?'].top(), i + 1});
        mp['?'].pop();
      }
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
