#include <bits/stdc++.h>
using namespace std;
vector<string> groups(string S) {
  vector<string> ret;
  for (int i = 0; i < (S.length()); i++) {
    if (ret.empty() || ret.back()[0] != S[i]) ret.push_back("");
    ret.back().push_back(S[i]);
  }
  return ret;
}
pair<string, string> split(vector<string> S, int k) {
  string a = "", b = "";
  for (int i = 0; i < (S.size()); i++) {
    if (i < k) {
      a += S[i];
    } else {
      b += S[i];
    }
  }
  return make_pair(a, b);
}
vector<pair<int, int> > solve2(string S, string T) {
  while (!S.empty() && S.back() == 'b') S.pop_back();
  while (!T.empty() && T.back() == 'a') T.pop_back();
  vector<int> A, B;
  for (int i = S.length() - 1; i >= 0; i--)
    if (i == S.length() - 1 || S[i + 1] != S[i]) A.push_back(i);
  for (int i = T.length() - 1; i >= 0; i--)
    if (i == T.length() - 1 || T[i + 1] != T[i]) B.push_back(i);
  while (A.size() < B.size()) A.push_back(-1);
  while (B.size() < A.size()) B.push_back(-1);
  vector<pair<int, int> > ret(A.size(), pair<int, int>(0, 0));
  for (int i = 0; i < (A.size()); i++) {
    if (i % 2 == 0)
      ret[i].first = A[i] + 1;
    else
      ret[i].second = A[i] + 1;
    if (i % 2 == 0)
      ret[i].second = B[i] + 1;
    else
      ret[i].first = B[i] + 1;
  }
  return ret;
}
vector<pair<int, int> > solve3(string S, string T) {
  vector<pair<int, int> > m1 = solve2(S, T);
  vector<pair<int, int> > m2 = solve2(T, S);
  if (m1.size() <= m2.size())
    return m1;
  else {
    for (pair<int, int> &p : m2) swap(p.first, p.second);
    return m2;
  }
}
vector<pair<int, int> > solve(string S, string T) {
  vector<string> ga = groups(S), gb = groups(T);
  bool flip = false;
  if (ga.size() < gb.size()) flip = true, swap(ga, gb), swap(S, T);
  vector<pair<int, int> > ret = solve3(S, T);
  for (int bf = 0; bf < (2); bf++) {
    int border = (2 * bf + ga.size() - gb.size()) / 2;
    for (int k = max(border - 10, 0); k < min(border + 10, (int)ga.size());
         k++) {
      auto p1 = split(ga, k), p2 = split(gb, bf);
      vector<pair<int, int> > seq =
          solve3(p2.first + p1.second, p1.first + p2.second);
      seq.insert(seq.begin(),
                 pair<int, int>(p1.first.length(), p2.first.length()));
      if (seq.size() < ret.size()) swap(ret, seq);
    }
  }
  if (flip)
    for (pair<int, int> &p : ret) swap(p.first, p.second);
  return ret;
}
string S, T;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> S >> T;
  vector<pair<int, int> > m = solve(S, T);
  cout << m.size() << "\n";
  for (pair<int, int> p : m) cout << p.first << " " << p.second << "\n";
  return 0;
}
