#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag = 0;
  cin >> n;
  int i;
  string s1, s2;
  cin >> s1 >> s2;
  vector<queue<int>> l(27);
  vector<queue<int>> r(27);
  for (i = 0; i < n; i++) {
    if (s1[i] == '?')
      l[0].push(i + 1);
    else if (s1[i] != '?')
      l[(int)s1[i] - 96].push(i + 1);
    if (s2[i] == '?')
      r[0].push(i + 1);
    else if (s2[i] != '?')
      r[(int)s2[i] - 96].push(i + 1);
  }
  vector<pair<int, int>> res;
  for (i = 1; i < 27; i++) {
    while (l[i].size() != 0 && r[i].size() != 0) {
      res.push_back(make_pair(l[i].front(), r[i].front()));
      l[i].pop();
      r[i].pop();
    }
    while (l[0].size() != 0 && r[i].size() != 0) {
      res.push_back(make_pair(l[0].front(), r[i].front()));
      l[0].pop();
      r[i].pop();
    }
    while (l[i].size() != 0 && r[0].size() != 0) {
      res.push_back(make_pair(l[i].front(), r[0].front()));
      l[i].pop();
      r[0].pop();
    }
  }
  while (l[0].size() != 0 && r[0].size() != 0) {
    res.push_back(make_pair(l[0].front(), r[0].front()));
    l[0].pop();
    r[0].pop();
  }
  cout << res.size() << "\n";
  for (i = 0; i < res.size(); i++) {
    cout << res[i].first << " " << res[i].second << endl;
  }
  return 0;
}
