#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string right, left;
  cin >> left;
  cin >> right;
  std::vector<int> rr[26];
  std::vector<int> lq;
  std::vector<int> rq;
  std::vector<int> ll[26];
  int cr = 0, cl = 0;
  for (int i = 0; i < n; ++i) {
    if (right[i] != '?')
      rr[right[i] - 'a' - 0].push_back(i + 1);
    else {
      cr++;
      rq.push_back(i + 1);
    }
    if (left[i] != '?')
      ll[left[i] - 'a' - 0].push_back(i + 1);
    else {
      cl++;
      lq.push_back(i + 1);
    }
  }
  int count = 0;
  std::vector<int> ans;
  for (int i = 0; i < 26; ++i) {
    int temp = min(rr[i].size(), ll[i].size());
    for (int j = 0; j < temp; ++j) {
      count++;
      ans.push_back(ll[i][j]);
      ans.push_back(rr[i][j]);
    }
    if (rr[i].size() > temp && cl != 0) {
      int mini;
      if (cl < rr[i].size() - temp)
        mini = cl;
      else
        mini = rr[i].size() - temp;
      for (int j = 0; j < mini; ++j) {
        count++;
        ans.push_back(lq[cl - 1]);
        ans.push_back(rr[i][j + temp]);
        cl--;
      }
    }
    if (ll[i].size() > temp && cr != 0) {
      int mini;
      if (cr < ll[i].size() - temp)
        mini = cr;
      else
        mini = ll[i].size() - temp;
      for (int j = 0; j < mini; ++j) {
        count++;
        ans.push_back(ll[i][j + temp]);
        ans.push_back(rq[cr - 1]);
        cr--;
      }
    }
  }
  int t = min(cl, cr);
  for (int i = 0; i < t; ++i) {
    count++;
    ans.push_back(lq[cl - 1]);
    ans.push_back(rq[cr - 1]);
    cr--;
    cl--;
  }
  cout << count << "\n";
  for (int i = 0; i < count; ++i) {
    if (ans[i * 2] <= 0 || ans[i * 2 + 1] <= 0) return i;
    cout << ans[i * 2] << " " << ans[i * 2 + 1] << "\n";
  }
  return 0;
}
