#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
const ll MOD = 1000000007ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll SUB(ll a, ll b) { return a - b >= 0ll ? a - b : a - b + MOD; }
inline ll ADD(ll a, ll b) { return a + b >= MOD ? a + b - MOD : a + b; }
inline ll MUL(ll a, ll b) { return a * b % MOD; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<char, set<int>> aid, bid;
  for (int i = (0), _for = ((n)); i < _for; i++) {
    char first;
    cin >> first;
    aid[first].insert(i);
  }
  for (int i = (0), _for = ((n)); i < _for; i++) {
    char first;
    cin >> first;
    bid[first].insert(i);
  }
  vector<pii> pairs;
  for (auto& [k, as] : aid) {
    if (k == '?') continue;
    auto& bs = bid[k];
    while (!bs.empty() && !as.empty()) {
      pairs.push_back({*begin(as), *begin(bs)});
      as.erase(begin(as));
      bs.erase(begin(bs));
    }
  }
  auto& a = aid['?'];
  auto& b = bid['?'];
  for (auto& [k, as] : aid) {
    if (b.empty()) break;
    if (k == '?') continue;
    while (!as.empty() && !b.empty()) {
      pairs.push_back({*begin(as), *begin(b)});
      b.erase(begin(b));
      as.erase(begin(as));
    }
  }
  for (auto& [k, bs] : bid) {
    if (k == '?') continue;
    if (a.empty()) break;
    while (!bs.empty() && !a.empty()) {
      pairs.push_back({*begin(a), *begin(bs)});
      a.erase(begin(a));
      bs.erase(begin(bs));
    }
  }
  while (!a.empty() && !b.empty()) {
    pairs.push_back({*begin(a), *begin(b)});
    a.erase(begin(a));
    b.erase(begin(b));
  }
  sort((pairs).begin(), (pairs).end());
  cout << (int)(pairs).size() << endl;
  for (auto [first, second] : pairs) {
    cout << (first + 1) << " " << (second + 1) << endl;
  }
}
