#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz?";
string _alpha = "abcdefghijklmnopqrstuvwxyz";
const long long mod = 1e9 + 7;
const long long inf = 1e18 + 5;
const long long nax = 2010;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  string l;
  string r;
  cin >> n >> l >> r;
  map<char, vector<long long>> cntl;
  map<char, vector<long long>> cntr;
  for (long long i = (0); i < (n); i++) {
    cntl[l[i]].push_back(i);
    cntr[r[i]].push_back(i);
  }
  vector<pair<long long, long long>> res;
  for (char z : _alpha) {
    while (!cntl[z].empty() && !cntr[z].empty()) {
      pair<long long, long long> p = {cntl[z][cntl[z].size() - 1],
                                      cntr[z][cntr[z].size() - 1]};
      cntl[z].pop_back();
      cntr[z].pop_back();
      res.push_back(p);
    }
  }
  if (!cntl['?'].empty()) {
    for (char z : _alpha) {
      while (!cntl['?'].empty() && !cntr[z].empty()) {
        pair<long long, long long> p = {cntl['?'][cntl['?'].size() - 1],
                                        cntr[z][cntr[z].size() - 1]};
        cntl['?'].pop_back();
        cntr[z].pop_back();
        res.push_back(p);
      }
    }
  }
  if (!cntr['?'].empty()) {
    for (char z : alpha) {
      while (!cntr['?'].empty() && !cntl[z].empty()) {
        pair<long long, long long> p = {cntl[z][cntl[z].size() - 1],
                                        cntr['?'][cntr['?'].size() - 1]};
        cntr['?'].pop_back();
        cntl[z].pop_back();
        res.push_back(p);
      }
    }
  }
  cout << res.size() << "\n";
  for (auto p : res) {
    cout << p.first + 1 << " " << p.second + 1 << "\n";
    ;
  }
  return 0;
}
