#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
int getSuffix(string &s, int x) {
  if (x == 0) return (int)(s).size();
  int cnt = 0;
  for (int i = (int)(s).size() - 2; i >= 0; --i) {
    if (s[i] != s[i + 1]) cnt++;
    if (cnt == x) return i + 1;
  }
  return 0;
}
vector<pii> f(string s, string t, int d) {
  if (s.back() != 'a') s += 'a';
  if (t.back() != 'b') t += 'b';
  int cntS = 1, cntT = 1;
  for (int(i) = (0); (i) < (int)((int)(s).size() - 1); ++(i))
    if (s[i] != s[i + 1]) cntS++;
  for (int(i) = (0); (i) < (int)((int)(t).size() - 1); ++(i))
    if (t[i] != t[i + 1]) cntT++;
  int posS = -1, posT = -1;
  if (cntS > cntT + 2) {
    posS = getSuffix(s, (cntS - cntT) / 2 + d);
    posT = getSuffix(t, 1);
  } else if (cntT > cntS + 2) {
    posS = getSuffix(s, 1);
    posT = getSuffix(t, (cntT - cntS) / 2 + d);
  }
  vector<pii> re;
  if (posS != -1) {
    string tmpS = s;
    s = t.substr(0, posT) + s.substr(posS);
    t = tmpS.substr(0, posS) + t.substr(posT);
    re.emplace_back(posS, posT);
  }
  while (1) {
    while ((int)(s).size() && s.back() == 'a') s.pop_back();
    while ((int)(t).size() && t.back() == 'b') t.pop_back();
    if (!(int)(s).size() && !(int)(t).size()) break;
    re.emplace_back((int)(s).size(), (int)(t).size());
    swap(s, t);
  }
  return re;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  string S, T;
  cin >> S >> T;
  vector<pii> ans{{-1, -1}};
  for (int(a) = (0); (a) < (int)(2); ++(a))
    for (int(d) = (0); (d) < (int)(3); ++(d)) {
      auto re = [&]() {
        if (!a) return f(S, T, d);
        auto re = f(T, S, d);
        for (auto &(r) : (re)) swap(r.first, r.second);
        return re;
      }();
      if (((int)(ans).size() == 1 && ans[0].first == -1) ||
          (int)(ans).size() > (int)(re).size())
        ans = re;
    }
  cout << (int)(ans).size() << endl;
  for (auto &(x) : (ans)) cout << x.first << ' ' << x.second << endl;
}
