#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long freq1[26] = {0};
  long long freq2[26] = {0};
  map<char, stack<long long>> mp1, mp2;
  long long mark1 = 0, mark2 = 0;
  long long n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  for (long long i = 0; i < s1.size(); i++) {
    if (s1[i] == '?')
      mark1++;
    else
      freq1[s1[i] - 'a']++;
    mp1[s1[i]].push(i + 1);
    if (s2[i] == '?')
      mark2++;
    else
      freq2[s2[i] - 'a']++;
    mp2[s2[i]].push(i + 1);
  }
  long long minn = 0, sum = 0, remain = 0;
  string ans = "";
  for (long long i = 0; i < 26;) {
    if (freq1[i] >= 1 && freq2[i] >= 1) {
      ans += to_string(mp1[(char)(i + 97)].top()) + " " +
             to_string(mp2[(char)(i + 97)].top()) + '\n';
      mp1[(char)(i + 97)].pop();
      mp2[(char)(i + 97)].pop();
      freq1[i]--;
      freq2[i]--;
      sum++;
    } else {
      i++;
    }
  }
  for (long long i = 0; i < 26; i++) remain += freq1[i] + freq2[i];
  for (long long i = 0; i < 26;) {
    if (freq1[i] != 0 && mark2 != 0) {
      ans += to_string(mp1[(char)(i + 97)].top()) + " " +
             to_string(mp2['?'].top()) + '\n';
      mp1[(char)(i + 97)].pop();
      mp2['?'].pop();
      freq1[i]--;
      mark2--;
      sum++;
    } else if (freq2[i] != 0 && mark1 != 0) {
      ans += to_string(mp1['?'].top()) + " " +
             to_string(mp2[(char)(i + 97)].top()) + '\n';
      mp1['?'].pop();
      mp2[(char)(i + 97)].pop();
      freq2[i]--;
      mark1--;
      sum++;
    } else {
      i++;
    }
  }
  long long akela = (mark1 + mark2) / 2;
  sum += akela;
  for (long long i = 0; i < akela; i++) {
    ans += to_string(mp1['?'].top()) + " " + to_string(mp2['?'].top()) + '\n';
    mp1['?'].pop();
    mp2['?'].pop();
  }
  cout << sum << '\n';
  cout << ans;
  return 0;
}
