#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using pii = pair<int, int>;
int getAns(int m, int n, bool same) {
  if (!same) return max(m, n) - 1;
  return 1 + min(getAns(m - 1, n, false), getAns(m, n - 1, false));
}
void print(int a, int b, bool swaped) {
  if (swaped) swap(a, b);
  cout << a << ' ' << b << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, pref, pref2, nr, ans, s1, s2;
  bool swaped;
  string s, ss, t, tt;
  cin >> s >> t;
  ss = s;
  tt = t;
  s.erase(unique(s.begin(), s.end()), s.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  if (s.length() > t.length())
    swap(s, t), swap(ss, tt), swaped = true;
  else
    swaped = false;
  nr = 0;
  ans = getAns(s.length(), t.length(), s[0] == t[0]);
  for (i = 0; i + 1 < t.length(); ++i) {
    int aux = 1 + getAns(i - (s[0] != t[i] && s.size() > 1) + s.length(),
                         t.length() - i - 1, t[0] == t[i + 1]);
    if (aux < ans) ans = aux, nr = i + 1;
  }
  cout << ans << '\n';
  if (nr) {
    for (pref = 0, i = 1; i <= nr; ++pref)
      if (tt[pref] != tt[pref + 1]) ++i;
    for (pref2 = 0; s[0] == t[nr]; ++pref2)
      if (ss[pref2] != ss[0]) break;
    --ans;
    print(pref2, pref, swaped);
    string aux = tt.substr(0, pref) + ss.substr(pref2);
    tt = ss.substr(0, pref2) + tt.substr(pref);
    ss = aux;
  }
  s = ss;
  t = tt;
  s.erase(unique(s.begin(), s.end()), s.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  if (ss[0] == tt[0]) {
    if (s.length() < t.length()) {
      for (i = 0; i < tt.length() && tt[i] == tt[0]; ++i)
        ;
      print(0, i, swaped);
      ss = tt.substr(0, i) + ss;
      tt = tt.substr(i);
    } else {
      for (i = 0; i < ss.length() && ss[i] == ss[0]; ++i)
        ;
      print(i, 0, swaped);
      tt = ss.substr(0, i) + tt;
      ss = ss.substr(i);
    }
    --ans;
  }
  for (s1 = s2 = 0, i = j = 0; ans;) {
    if (i < ss.length()) {
      while (i + 1 < ss.length() && ss[i] == ss[i + 1]) ++i, ++s1;
      ++i;
      ++s1;
    }
    if (j < tt.length()) {
      while (j + 1 < tt.length() && tt[j] == tt[j + 1]) ++j, ++s2;
      ++j;
      ++s2;
    }
    --ans;
    print(s1, s2, swaped);
    swap(s1, s2);
  }
  return 0;
}
