#include <bits/stdc++.h>
using namespace std;
const int N = 150100;
queue<int> l[300], r[300];
queue<int> li, ri;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    if (s1[i] == '?') {
      li.push(i);
    } else {
      l[s1[i] - 'a'].push(i);
    }
    if (s2[i] == '?') {
      ri.push(i);
    } else {
      r[s2[i] - 'a'].push(i);
    }
  }
  vector<pair<int, int>> ans;
  for (int i = 0; i < 26; i++) {
    int a = l[i].size(), b = r[i].size();
    int k = min(a, b);
    for (int j = 0; j < k; j++) {
      ans.push_back({l[i].front(), r[i].front()});
      l[i].pop();
      r[i].pop();
    }
    while (l[i].size() && ri.size()) {
      ans.push_back({l[i].front(), ri.front()});
      l[i].pop();
      ri.pop();
    }
    while (r[i].size() && li.size()) {
      ans.push_back({li.front(), r[i].front()});
      r[i].pop();
      li.pop();
    }
  }
  while (li.size() && ri.size()) {
    ans.push_back({li.front(), ri.front()});
    li.pop();
    ri.pop();
  }
  cout << ans.size() << "\n";
  for (auto a : ans) {
    cout << a.first + 1 << " " << a.second + 1 << "\n";
  }
  return 0;
}
