#include <bits/stdc++.h>
using namespace std;
map<char, int> a;
map<char, int> b;
map<char, set<int>> a1;
map<char, set<int>> b1;
vector<pair<int, int>> ans;
int main() {
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  for (int i = 0; i < s1.length(); i++) {
    a[s1[i]]++;
    a1[s1[i]].insert(i);
  }
  for (int i = 0; i < s2.length(); i++) {
    b[s2[i]]++;
    b1[s2[i]].insert(i);
  }
  for (char i = 'a'; i <= 'z'; i++) {
    int m = min(a[i], b[i]);
    a[i] -= m;
    b[i] -= m;
    for (int j = 0; j < m; j++) {
      ans.push_back({*a1[i].begin(), *b1[i].begin()});
      a1[i].erase(*a1[i].begin());
      b1[i].erase(*b1[i].begin());
    }
  }
  int q = a['?'];
  for (auto i : b) {
    if (i.first != '?') {
      int m = i.second;
      if (q < m) {
        b[i.first] -= q;
        int ty = q;
        for (int j = 0; j < ty; j++) {
          ans.push_back({*a1['?'].begin(), *b1[i.first].begin()});
          a1['?'].erase(*a1['?'].begin());
          b1[i.first].erase(*b1[i.first].begin());
          q--;
        }
      } else {
        b[i.first] -= m;
        for (int j = 0; j < m; j++) {
          ans.push_back({*a1['?'].begin(), *b1[i.first].begin()});
          a1['?'].erase(*a1['?'].begin());
          b1[i.first].erase(*b1[i.first].begin());
          q--;
        }
      }
    }
    if (q == 0) break;
  }
  a['?'] = q;
  q = b['?'];
  for (auto i : a) {
    int m = i.second;
    if (q < m) {
      int ty = q;
      for (int j = 0; j < ty; j++) {
        ans.push_back({*a1[i.first].begin(), *b1['?'].begin()});
        a1[i.first].erase(*a1[i.first].begin());
        b1['?'].erase(*b1['?'].begin());
        q--;
      }
    } else {
      for (int j = 0; j < m; j++) {
        ans.push_back({*a1[i.first].begin(), *b1['?'].begin()});
        a1[i.first].erase(*a1[i.first].begin());
        b1['?'].erase(*b1['?'].begin());
        q--;
      }
    }
    if (q == 0) break;
  }
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.first + 1 << ' ' << i.second + 1 << endl;
  }
  return 0;
}
