#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  set<int> qmarka;
  set<int> qmarkb;
  vector<pair<int, int>> vec;
  set<int> s[26];
  for (int i = 0; i < n; i++) {
    if (a[i] == '?')
      qmarka.insert(i);
    else
      s[a[i] - 'a'].insert(i);
  }
  for (int i = 0; i < n; i++) {
    if (b[i] == '?')
      qmarkb.insert(i);
    else {
      bool found = false;
      for (auto itr : s[b[i] - 'a']) {
        found = true;
        vec.push_back(make_pair(i, itr));
        s[b[i] - 'a'].erase(itr);
        break;
      }
      if (!found) {
        for (auto itr : qmarka) {
          found = true;
          vec.push_back(make_pair(i, itr));
          qmarka.erase(itr);
          break;
        }
      }
    }
  }
  int next = 0;
  for (auto itr1 : qmarkb) {
    while (next < 26 && s[next].size() == 0) next++;
    if (next == 26) {
      for (auto itr : qmarka) {
        vec.push_back(make_pair(itr1, itr));
        qmarka.erase(itr);
        break;
      }
    } else
      for (auto itr : s[next]) {
        vec.push_back(make_pair(itr1, itr));
        s[next].erase(itr);
        break;
      }
  }
  cout << vec.size() << '\n';
  for (auto itr : vec) cout << itr.second + 1 << ' ' << itr.first + 1 << '\n';
  int dont_hack_please;
}
