#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;
const int INF = 1e9;
int n;
string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s >> t;
  V<V<int> > sc(27), tc(27);
  V<int> sq, tq;
  for (int i = 0; i < n; i++) {
    if (s[i] != '?')
      sc[s[i] - 'a'].emplace_back(i);
    else
      sq.emplace_back(i);
    if (t[i] != '?')
      tc[t[i] - 'a'].emplace_back(i);
    else
      tq.emplace_back(i);
  }
  V<P<int, int> > ans;
  V<int> srem, trem;
  for (int i = 0; i < 26; i++) {
    while (sc[i].size() > 0 && tc[i].size()) {
      ans.emplace_back(sc[i].back(), tc[i].back());
      sc[i].pop_back(), tc[i].pop_back();
    }
    if (sc[i].size() > 0)
      for (int j = 0; j < sc[i].size(); j++) srem.emplace_back(sc[i][j]);
    if (tc[i].size() > 0)
      for (int j = 0; j < tc[i].size(); j++) trem.emplace_back(tc[i][j]);
  }
  while (sq.size() > 0 && trem.size() > 0) {
    ans.emplace_back(sq.back(), trem.back());
    sq.pop_back(), trem.pop_back();
  }
  while (tq.size() > 0 && srem.size() > 0) {
    ans.emplace_back(srem.back(), tq.back());
    tq.pop_back(), srem.pop_back();
  }
  while (tq.size() > 0 && sq.size() > 0) {
    ans.emplace_back(sq.back(), tq.back());
    tq.pop_back(), sq.pop_back();
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
  }
  return 0;
}
