#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;
std::vector<ll> v[30], vv[30];
std::vector<ll> x, xx;
std::vector<pair<ll, ll>> vvv;
ll res;
void solve() {
  ll n;
  cin >> n;
  string s, ss;
  cin >> s >> ss;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '?') x.push_back(i + 1);
    if (ss[i] == '?') xx.push_back(i + 1);
    if (s[i] != '?') v[s[i] - 'a'].push_back(i + 1);
    if (ss[i] != '?') vv[ss[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < 30; ++i) {
    while (v[i].size() && vv[i].size()) {
      vvv.push_back({v[i].back(), vv[i].back()});
      v[i].pop_back();
      vv[i].pop_back();
    }
  }
  for (int i = 0; i < 30; ++i) {
    while (x.size() && vv[i].size()) {
      vvv.push_back({x.back(), vv[i].back()});
      x.pop_back();
      vv[i].pop_back();
    }
  }
  for (int i = 0; i < 30; ++i) {
    while (xx.size() && v[i].size()) {
      vvv.push_back({v[i].back(), xx.back()});
      xx.pop_back();
      v[i].pop_back();
    }
  }
  while (x.size() && xx.size()) {
    vvv.push_back({x.back(), xx.back()});
    x.pop_back();
    xx.pop_back();
  }
  cout << vvv.size() << "\n";
  for (auto i : vvv) {
    cout << i.first << " " << i.second << "\n";
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
