#include <bits/stdc++.h>
using namespace std;
long long int arr[500001];
int main() {
  long long int x, t, i, j, k, l, m, n, c = 0, flag, ans = 0;
  string str1, str2;
  cin >> n;
  cin >> str1;
  map<int, vector<int> > m1, m2;
  for (i = 1; i <= str1.length(); i++) {
    if (str1[i - 1] == '?') {
      m1[26].push_back(i);
      continue;
    }
    m1[str1[i - 1] - 'a'].push_back(i);
  }
  cin >> str2;
  for (i = 1; i <= str2.length(); i++) {
    if (str2[i - 1] == '?') {
      m2[26].push_back(i);
      continue;
    }
    m2[str2[i - 1] - 'a'].push_back(i);
  }
  long long int c1 = 0, c2 = 0;
  vector<pair<long long int, long long int> > anss;
  for (i = 0; i <= 25; i++) {
    ans = ans + min(m1[i].size(), m2[i].size());
    for (j = 0; j < min(m1[i].size(), m2[i].size()); j++) {
      anss.push_back({m1[i][j], m2[i][j]});
    }
    for (k = j; k < m1[i].size(); k++) {
      if (c1 < m2[26].size()) {
        anss.push_back({m1[i][k], m2[26][c1]});
        c1++;
      } else
        break;
    }
    for (k = j; k < m2[i].size(); k++) {
      if (c2 < m1[26].size()) {
        anss.push_back({m1[26][c2], m2[i][k]});
        c2++;
      } else
        break;
    }
  }
  while (c1 < m2[26].size() && c2 < m1[26].size()) {
    anss.push_back({m1[26][c2], m2[26][c1]});
    c1++;
    c2++;
  }
  ans = anss.size();
  cout << ans << endl;
  for (i = 0; i < anss.size(); i++)
    cout << anss[i].first << " " << anss[i].second << endl;
  return 0;
}
