#include <bits/stdc++.h>
using namespace std;
long long int mo = 1000000007;
bool greed(const pair<int, int> a, const pair<int, int> b) {
  return (a.first - a.second) > (b.first - b.second);
}
queue<int> a[28], b[28];
int main() {
  int n;
  cin >> n;
  string l, r;
  cin >> l >> r;
  for (int i = 0; i < n; i++) {
    if (l[i] == '?')
      a[26].push(i + 1);
    else {
      int x = l[i] - 'a';
      a[x].push(i + 1);
    }
    if (r[i] == '?')
      b[26].push(i + 1);
    else {
      int x = r[i] - 'a';
      b[x].push(i + 1);
    }
  }
  vector<pair<int, int> > vec;
  for (int i = 0; i < 27; i++) {
    while (!a[i].empty() && !b[i].empty()) {
      int x1 = a[i].front();
      a[i].pop();
      int x2 = b[i].front();
      b[i].pop();
      vec.push_back(make_pair(x1, x2));
    }
    while (!a[i].empty() && !b[26].empty()) {
      int x1 = a[i].front();
      a[i].pop();
      int x2 = b[26].front();
      b[26].pop();
      vec.push_back(make_pair(x1, x2));
    }
    while (!a[26].empty() && !b[i].empty()) {
      int x1 = a[26].front();
      a[26].pop();
      int x2 = b[i].front();
      b[i].pop();
      vec.push_back(make_pair(x1, x2));
    }
  }
  cout << vec.size() << endl;
  for (auto i : vec) {
    cout << i.first << " " << i.second << endl;
  }
}
