#include <bits/stdc++.h>
using namespace std;
const int N = 220000;
char a[N], b[N];
int cnt[2][N];
int deg[2][N];
vector<int> v1[N], v2[N];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  cin >> a >> b;
  for (int i = 0; a[i]; i++) v1[a[i]].push_back(i);
  for (int i = 0; b[i]; i++) v2[b[i]].push_back(i);
  for (int i = 0; a[i]; i++) cnt[0][a[i]]++;
  for (int i = 0; b[i]; i++) cnt[1][b[i]]++;
  vector<pair<int, int>> ans;
  for (int i = 0; i < N; i++) {
    if (i == '?') continue;
    deg[0][i] = deg[1][i] = min(cnt[0][i], cnt[1][i]);
    for (int j = 0; j < deg[0][i]; j++) {
      ans.emplace_back(v1[i].back(), v2[i].back());
      v1[i].pop_back();
      v2[i].pop_back();
    }
    cnt[0][i] -= deg[0][i];
    cnt[1][i] -= deg[1][i];
  }
  for (int i = 0; i < N; i++) {
    if (i == '?') continue;
    int cur = min(cnt[0]['?'], cnt[1][i]);
    cnt[0]['?'] -= cur;
    cnt[1][i] -= cur;
    deg[1][i] += cur;
    deg[0]['?'] += cur;
    for (int j = 0; j < cur; j++) {
      ans.emplace_back(v1['?'].back(), v2[i].back());
      v1['?'].pop_back();
      v2[i].pop_back();
    }
    cur = min(cnt[1]['?'], cnt[0][i]);
    cnt[1]['?'] -= cur;
    cnt[0][i] -= cur;
    deg[0][i] += cur;
    deg[1]['?'] += cur;
    for (int j = 0; j < cur; j++) {
      ans.emplace_back(v1[i].back(), v2['?'].back());
      v1[i].pop_back();
      v2['?'].pop_back();
    }
  }
  int cur = min(cnt[0]['?'], cnt[1]['?']);
  cnt[0]['?'] -= cur, cnt[1]['?'] -= cur;
  deg[0]['?'] += cur, deg[1]['?'] += cur;
  for (int i = 0; i < cur; i++) {
    ans.emplace_back(v1['?'].back(), v2['?'].back());
    v1['?'].pop_back();
    v2['?'].pop_back();
  }
  cout << ans.size() << endl;
  for (auto it : ans) cout << it.first + 1 << " " << it.second + 1 << endl;
  return 0;
}
