#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int nn;
  cin >> nn;
  cin >> s1 >> s2;
  list<int> f1[27], f2[27];
  map<int, int> s;
  map<int, int>::iterator is;
  int c = 0;
  for (int i = 0; s1[i]; i++) {
    if (s1[i] == '?') {
      f1[26].push_back(i);
    } else
      f1[s1[i] - 'a'].push_back(i);
    if (s2[i] == '?') {
      f2[26].push_back(i);
    } else
      f2[s2[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    if (!f1[i].empty() && !f2[i].empty()) {
      c += min(f1[i].size(), f2[i].size());
      if (f1[i].size() != f2[i].size()) {
        if (f1[i].size() > f2[i].size()) {
          while (f2[i].size() > 0) {
            s[f1[i].front()] = f2[i].front();
            f1[i].pop_front();
            f2[i].pop_front();
          }
          if (!f1[26].empty()) {
            if (f1[i].size() > f2[26].size()) {
              while (f2[26].size() > 0) {
                s[f1[i].front()] = f2[26].front();
                f1[i].pop_front();
                f2[26].pop_front();
                c++;
              }
            } else {
              while (f1[i].size() > 0) {
                s[f1[i].front()] = f2[26].front();
                f1[i].pop_front();
                f2[26].pop_front();
                c++;
              }
            }
          }
        } else {
          while (f1[i].size() > 0) {
            s[f1[i].front()] = f2[i].front();
            f1[i].pop_front();
            f2[i].pop_front();
          }
          if (!f1[26].empty()) {
            if (f2[i].size() > f1[26].size()) {
              while (f1[26].size() > 0) {
                s[f1[26].front()] = f2[i].front();
                f2[i].pop_front();
                f1[26].pop_front();
                c++;
              }
            } else {
              while (f2[i].size() > 0) {
                s[f1[26].front()] = f2[i].front();
                f2[i].pop_front();
                f1[26].pop_front();
                c++;
              }
            }
          }
        }
      } else {
        while (f1[i].size() > 0) {
          s[f1[i].front()] = f2[i].front();
          f1[i].pop_front();
          f2[i].pop_front();
        }
      }
    } else {
      if (!f1[i].empty()) {
        if (!f2[26].empty()) {
          if (f1[i].size() > f2[26].size()) {
            while (f2[26].size() > 0) {
              s[f1[i].front()] = f2[26].front();
              f1[i].pop_front();
              f2[26].pop_front();
              c++;
            }
          } else {
            while (f1[i].size() > 0) {
              s[f1[i].front()] = f2[26].front();
              f1[i].pop_front();
              f2[26].pop_front();
              c++;
            }
          }
        }
      } else if (!f2[i].empty()) {
        if (!f1[26].empty()) {
          if (f2[i].size() > f1[26].size()) {
            while (f1[26].size() > 0) {
              s[f1[26].front()] = f2[i].front();
              f2[i].pop_front();
              f1[26].pop_front();
              c++;
            }
          } else {
            while (f2[i].size() > 0) {
              s[f1[26].front()] = f2[i].front();
              f2[i].pop_front();
              f1[26].pop_front();
              c++;
            }
          }
        }
      }
    }
  }
  if (!f1[26].empty() && !f2[26].empty()) {
    if (f1[26].size() > f2[26].size()) {
      while (f2[26].size() > 0) {
        s[f1[26].front()] = f2[26].front();
        f1[26].pop_front();
        f2[26].pop_front();
        c++;
      }
    } else {
      while (f1[26].size() > 0) {
        s[f1[26].front()] = f2[26].front();
        f1[26].pop_front();
        f2[26].pop_front();
        c++;
      }
    }
  }
  if (!f1[26].empty()) {
    for (int i = 0; i < 26; i++) {
      if (!f2[i].empty()) {
        if (f2[i].size() > f1[26].size()) {
          while (f1[26].size() > 0) {
            s[f1[26].front()] = f2[i].front();
            f2[i].pop_front();
            f1[26].pop_front();
            c++;
          }
        } else {
          while (f2[i].size() > 0) {
            s[f1[26].front()] = f2[i].front();
            f2[i].pop_front();
            f1[26].pop_front();
            c++;
          }
        }
      }
    }
  }
  if (!f2[26].empty()) {
    for (int i = 0; i < 26; i++) {
      if (!f1[i].empty()) {
        if (f1[i].size() > f2[26].size()) {
          while (f2[26].size() > 0) {
            s[f1[i].front()] = f2[26].front();
            f1[i].pop_front();
            f2[26].pop_front();
            c++;
          }
        } else {
          while (f1[i].size() > 0) {
            s[f1[i].front()] = f2[26].front();
            f1[i].pop_front();
            f2[26].pop_front();
            c++;
          }
        }
      }
    }
  }
  cout << c << endl;
  for (is = s.begin(); is != s.end(); is++) {
    cout << is->first + 1 << " " << is->second + 1 << endl;
  }
}
