#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 * 1000 + 100;
vector<pair<int, int> > res;
vector<int> l[30];
vector<int> r[30];
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; i++) {
    if (s[i] == '?')
      l[26].push_back(i);
    else
      l[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (t[i] == '?')
      r[26].push_back(i);
    else
      r[t[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    while (!l[i].empty() && !r[i].empty()) {
      res.push_back(make_pair(l[i].back() + 1, r[i].back() + 1));
      l[i].pop_back(), r[i].pop_back();
    }
  }
  for (int i = 0; i < 26; i++) {
    while (!l[i].empty() && !r[26].empty()) {
      res.push_back(make_pair(l[i].back() + 1, r[26].back() + 1));
      l[i].pop_back(), r[26].pop_back();
    }
  }
  for (int i = 0; i <= 26; i++) {
    while (!l[26].empty() && !r[i].empty()) {
      res.push_back(make_pair(l[26].back() + 1, r[i].back() + 1));
      l[26].pop_back(), r[i].pop_back();
    }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first << ' ' << res[i].second << endl;
  return 0;
}
