#include <bits/stdc++.h>
using namespace std;
const int MN = 2e5 + 5;
int N, K, A[MN], B[MN], vL, vR, cnt;
vector<int> cntL[30], cntR[30];
vector<pair<int, int> > ans;
string L, R;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> N >> L >> R;
  for (int i = 0; i < N; i++) {
    A[i] = L[i] - 'a';
    B[i] = R[i] - 'a';
    if (L[i] == '?') A[i] = 26;
    if (R[i] == '?') B[i] = 26;
    cntL[A[i]].push_back(i + 1);
    cntR[B[i]].push_back(i + 1);
  }
  for (int i = 0; i <= 26; i++) {
    while (cntL[i].size() && cntR[i].size()) {
      ans.push_back(pair<int, int>(cntL[i][cntL[i].size() - 1],
                                   cntR[i][cntR[i].size() - 1]));
      cnt++;
      cntL[i].pop_back();
      cntR[i].pop_back();
    }
    while (cntL[i].size() && cntR[26].size()) {
      ans.push_back(pair<int, int>(cntL[i][cntL[i].size() - 1],
                                   cntR[26][cntR[26].size() - 1]));
      cnt++;
      cntL[i].pop_back();
      cntR[26].pop_back();
    }
    while (cntL[26].size() && cntR[i].size()) {
      ans.push_back(pair<int, int>(cntL[26][cntL[26].size() - 1],
                                   cntR[i][cntR[i].size() - 1]));
      cnt++;
      cntL[26].pop_back();
      cntR[i].pop_back();
    }
  }
  cout << cnt << '\n';
  for (pair<int, int> x : ans) {
    cout << x.first << ' ' << x.second << '\n';
  }
}
