#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long n;
  cin >> n;
  string s, second;
  cin >> s;
  cin >> second;
  queue<long long> adj1[27];
  queue<long long> adj2[27];
  for (long long i = 0; i < n; i++) {
    if (s[i] == '?')
      adj1[26].push(i);
    else
      adj1[s[i] - 'a'].push(i);
    if (second[i] == '?')
      adj2[26].push(i);
    else
      adj2[second[i] - 'a'].push(i);
  }
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < 26; i++) {
    while (adj1[i].size() != 0 && adj2[i].size() != 0) {
      v.push_back(make_pair(adj1[i].front(), adj2[i].front()));
      adj1[i].pop();
      adj2[i].pop();
    }
    while (adj1[i].size() != 0 && adj2[26].size() != 0) {
      v.push_back(make_pair(adj1[i].front(), adj2[26].front()));
      adj1[i].pop();
      adj2[26].pop();
    }
    while (adj1[26].size() != 0 && adj2[i].size() != 0) {
      v.push_back(make_pair(adj1[26].front(), adj2[i].front()));
      adj1[26].pop();
      adj2[i].pop();
    }
  }
  while (adj1[26].size() != 0 && adj2[26].size() != 0) {
    v.push_back(make_pair(adj1[26].front(), adj2[26].front()));
    adj1[26].pop();
    adj2[26].pop();
  }
  cout << v.size() << endl;
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i].first + 1 << " " << v[i].second + 1 << endl;
  }
  return 0;
}
