#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  vector<long long> l[26], r[26];
  vector<long long> k1, k2;
  for (long long i = 0; i < n; i++) {
    if (s1[i] >= 'a' && s1[i] <= 'z') {
      l[s1[i] - 'a'].push_back(i + 1);
    } else
      k1.push_back(i + 1);
  }
  for (long long i = 0; i < n; i++) {
    if (s2[i] >= 'a' && s2[i] <= 'z') {
      r[s2[i] - 'a'].push_back(i + 1);
    } else
      k2.push_back(i + 1);
  }
  vector<pair<long long, long long> > ans;
  for (long long i = 0; i < 26; i++) {
    while (!l[i].empty() && !r[i].empty()) {
      long long x = l[i].back();
      l[i].pop_back();
      long long y = r[i].back();
      r[i].pop_back();
      ans.push_back({x, y});
    }
  }
  for (long long i = 0; i < 26; i++) {
    while (!l[i].empty() && !k2.empty()) {
      long long x = l[i].back();
      l[i].pop_back();
      long long y = k2.back();
      k2.pop_back();
      ans.push_back({x, y});
    }
  }
  for (long long i = 0; i < 26; i++) {
    while (!k1.empty() && !r[i].empty()) {
      long long x = k1.back();
      k1.pop_back();
      long long y = r[i].back();
      r[i].pop_back();
      ans.push_back({x, y});
    }
  }
  for (long long i = 0; i < (long long)min(k1.size(), k2.size()); i++) {
    ans.push_back({k1[i], k2[i]});
  }
  cout << ans.size() << "\n";
  for (auto i : ans) {
    cout << i.first << " " << i.second << "\n";
  }
}
