#include <bits/stdc++.h>
using namespace std;
long long int dif(long long int a, long long int b) {
  return ((a / b) + (a % b != 0));
}
vector<long long int> a[26], b[26], v1, v2, v3, v4;
vector<pair<long long int, long long int> > sol;
long long int ans;
long long int n;
string s, t;
bool f1[200200], f2[200200];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s >> t;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '?')
      v1.push_back(i + 1);
    else
      a[s[i] - 'a'].push_back(i + 1);
    if (t[i] == '?')
      v2.push_back(i + 1);
    else
      b[t[i] - 'a'].push_back(i + 1);
  }
  for (long long int i = 0; i < 26; i++) {
    for (long long int j = 0; j < min(a[i].size(), b[i].size()); j++) {
      sol.push_back({a[i][j], b[i][j]});
      ans++;
      f1[a[i][j] - 1] = true;
      f2[b[i][j] - 1] = true;
    }
  }
  long long int k = 0;
  for (long long int i = 0; i < v1.size(); i++) {
    for (long long int j = k; j < n; j++) {
      k = j;
      if (!f2[j] && t[j] != '?') {
        sol.push_back({v1[i], j + 1});
        f1[v1[i] - 1] = true;
        f2[j] = true;
        ans++;
        break;
      }
    }
  }
  k = 0;
  for (long long int i = 0; i < v2.size(); i++) {
    for (long long int j = k; j < n; j++) {
      k = j;
      if (!f1[j] && s[j] != '?') {
        sol.push_back({j + 1, v2[i]});
        f1[j] = true;
        f2[v2[i] - 1] = true;
        ans++;
        break;
      }
    }
  }
  k = 0;
  for (long long int i = 0; i < v1.size(); i++) {
    if (f1[v1[i] - 1]) continue;
    for (long long int j = k; j < v2.size(); j++) {
      k = j;
      if (f2[v2[j] - 1])
        continue;
      else {
        sol.push_back({v1[i], v2[j]});
        f1[v1[i] - 1] = f2[v2[j] - 1] = true;
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  for (auto s : sol) cout << s.first << " " << s.second << endl;
  return 0;
}
