#include <bits/stdc++.h>
using namespace std;
const int maxn = 150000 + 10;
string l, r;
vector<int> vl[30], vr[30];
stack<int> cl, cr;
vector<pair<int, int> > ans;
int n, vis_l[maxn], vis_r[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l >> r;
  for (int i = 0; i < n; i++) {
    if (l[i] == '?') {
      cl.push(i);
      vis_l[i] = 1;
    } else
      vl[l[i] - 'a'].push_back(i);
    if (r[i] == '?') {
      cr.push(i);
      vis_r[i] = 1;
    } else
      vr[r[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < min(vl[i].size(), vr[i].size()); j++) {
      ans.push_back(make_pair(vl[i][j], vr[i][j]));
      vis_l[vl[i][j]] = 1;
      vis_r[vr[i][j]] = 1;
    }
  }
  for (int i = 0; !cr.empty() && i < n; i++)
    if (!vis_l[i]) {
      ans.push_back(make_pair(i, cr.top()));
      cr.pop();
    }
  for (int i = 0; !cl.empty() && i < n; i++)
    if (!vis_r[i]) {
      ans.push_back(make_pair(cl.top(), i));
      cl.pop();
    }
  while (!cr.empty() && !cl.empty()) {
    ans.push_back(make_pair(cl.top(), cr.top()));
    cl.pop();
    cr.pop();
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
}
