#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1000 * 1000 + 10;
int main() {
  int n;
  cin >> n;
  string l, r;
  cin >> l >> r;
  map<char, queue<int>> mp;
  map<char, bool> check;
  map<int, bool> check1, check2;
  int cnt = 1;
  for (auto i : r) {
    check[i] = true;
    mp[i].push(cnt);
    cnt++;
  }
  vector<pair<int, int>> res;
  pair<int, int> p;
  cnt = 1;
  for (auto e : l) {
    if (check[e] && e != '?') {
      if (mp[e].size() != 0) {
        p.first = cnt;
        p.second = mp[e].front();
        mp[e].pop();
        check1[cnt] = true;
        check2[p.second] = true;
        res.push_back(p);
      }
    }
    if (e == '?') {
      mp['*'].push(cnt);
    }
    cnt++;
  }
  cnt = 1;
  for (auto e : r) {
    if (check2[cnt] == false && e != '?' && mp['*'].size() != 0) {
      p.first = mp['*'].front();
      p.second = cnt;
      res.push_back(p);
      check1[p.first] = true;
      check2[p.second] = true;
      mp['*'].pop();
    }
    cnt++;
  }
  cnt = 1;
  for (auto e : l) {
    if (check1[cnt] == false && e != '?' && mp['?'].size() != 0) {
      p.first = cnt;
      p.second = mp['?'].front();
      res.push_back(p);
      check1[cnt] = true;
      check2[p.second] = true;
      mp['?'].pop();
    }
    cnt++;
  }
  while (mp['*'].size() != 0 && mp['?'].size() != 0) {
    p.first = mp['*'].front();
    p.second = mp['?'].front();
    mp['*'].pop();
    mp['?'].pop();
    res.push_back(p);
  }
  cout << res.size() << endl;
  for (auto e : res) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}
