#include <bits/stdc++.h>
using namespace std;
queue<long long> g[256];
int main() {
  long long n;
  vector<pair<long long, long long> > an;
  string s, ss;
  cin >> n >> s >> ss;
  for (long long i = 0; i < ss.size(); i++) g[ss[i]].push(i);
  for (long long i = 0; i < s.size(); i++)
    if (s[i] != '?') {
      if (g[s[i]].empty() == 0) {
        an.push_back(pair<long long, long long>(i + 1, g[s[i]].front() + 1));
        ss[g[s[i]].front()] = ' ';
        g[s[i]].pop();
        s[i] = ' ';
      } else if (g['?'].empty() == 0) {
        an.push_back(pair<long long, long long>(i + 1, g['?'].front() + 1));
        ss[g['?'].front()] = ' ';
        g['?'].pop();
        s[i] = ' ';
      }
    }
  long long j = 0;
  for (long long i = 0; i < n; i++)
    if (s[i] == '?') {
      while (j < n) {
        if (ss[j] != ' ') {
          an.push_back(pair<long long, long long>(i + 1, j + 1));
          j++;
          break;
        }
        j++;
      }
    }
  cout << an.size() << endl;
  for (long long i = 0; i < an.size(); i++)
    cout << an[i].first << " " << an[i].second << endl;
}
