#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
using namespace std;
vector<pair<long long, long long> > ans;
bool vyh = false;
void tr(vector<pair<long long, long long> > &small,
        vector<pair<long long, long long> > &large, bool inv) {
  pair<long long, long long> F = large.back();
  large.pop_back();
  pair<long long, long long> S = large.back();
  large.pop_back();
  pair<long long, long long> T = small.back();
  pair<long long, long long> aa = make_pair(T.second, F.second + S.second);
  if (inv) swap(aa.first, aa.second);
  small.back().second = F.second;
  small[small.size() - 2].second += S.second;
  large.back().second += T.second;
  ans.push_back(aa);
}
void normir(vector<pair<long long, long long> > &a,
            vector<pair<long long, long long> > &b, bool inv) {
  long long cut = 1;
  while (cut <= b.size()) {
    long long B = b.size() - cut + 1;
    long long A = a.size() + cut - 1;
    if (a.size() == 1) A++;
    if (b.size() == 1) B++;
    if (abs(A - B) <= 1 && !(cut == 1 && b.size() == 1)) {
      long long S = 0;
      for (long long j = 0; j < cut; j++) S += b[b.size() - j - 1].second;
      ans.push_back(make_pair(a.back().second, S));
      if (inv) {
        swap(ans.back().first, ans.back().second);
      }
      pair<long long, long long> p = a.back();
      a.pop_back();
      vector<pair<long long, long long> > rt;
      for (long long i = 0; i < cut - 1; i++) {
        pair<long long, long long> q = b.back();
        b.pop_back();
        rt.push_back(q);
      }
      pair<long long, long long> e = b.back();
      b.pop_back();
      if (a.size())
        a[a.size() - 1].second += e.second;
      else
        a.push_back(e);
      if (b.size())
        b.back().second += p.second;
      else
        b.push_back(p);
      reverse(rt.begin(), rt.end());
      for (long long i = 0; i < rt.size(); i++) a.push_back(rt[i]);
      return;
    }
    cut += 2;
  }
  cut = 1;
  while (cut <= b.size()) {
    long long B = b.size() - cut;
    long long A = a.size() + cut;
    if (a.size() == 1) A++;
    if (b.size() == 1) B++;
    if (abs(A - B) <= 1 && !(cut == 1 && b.size() == 1)) {
      long long S = 0;
      for (long long j = 0; j < cut; j++) S += b[b.size() - j - 1].second;
      ans.push_back(make_pair(0, S));
      if (inv) {
        swap(ans.back().first, ans.back().second);
      }
      vector<pair<long long, long long> > rt;
      for (long long i = 0; i < cut; i++) {
        pair<long long, long long> q = b.back();
        b.pop_back();
        rt.push_back(q);
      }
      reverse(rt.begin(), rt.end());
      for (long long i = 0; i < rt.size(); i++) a.push_back(rt[i]);
      return;
    }
    cut += 2;
  }
}
void solve2(vector<pair<long long, long long> > &a,
            vector<pair<long long, long long> > &b) {
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  vyh = true;
  if (a.size() < b.size())
    normir(a, b, false);
  else if (b.size() < a.size())
    normir(b, a, true);
  long long S = 0;
  for (long long i = 0; i < a.size(); i++) S += a[i].second;
  long long sz = min(a.size(), b.size());
  for (long long i = 0; i < sz - 1; i++) {
    pair<long long, long long> p = a.back();
    a.pop_back();
    pair<long long, long long> q = b.back();
    b.pop_back();
    ans.push_back(make_pair(p.second, q.second));
    a.back().second += q.second;
    b.back().second += p.second;
  }
  if (a.size() == 1 && b.size() == 1) return;
  ans.push_back(make_pair(a.back().second, b.back().second));
  return;
}
void sv(vector<pair<long long, long long> > &a,
        vector<pair<long long, long long> > &b, bool inv) {
  if (b.size() == 2) {
    ans.push_back(make_pair(0, b.back().second));
    if (inv) {
      swap(ans.back().first, ans.back().second);
    }
    return;
  }
  ans.push_back(make_pair(0, b.back().second));
  if (inv) {
    swap(ans.back().first, ans.back().second);
  }
  ans.push_back(
      make_pair(a.back().second + b.back().second, b[b.size() - 2].second));
  if (inv) {
    swap(ans.back().first, ans.back().second);
  }
  return;
}
void s1(vector<pair<long long, long long> > &a,
        vector<pair<long long, long long> > &b, bool inv) {
  if (b.size() <= 3) return;
  if (b.size() % 4 == 2) {
    long long S = 0;
    vector<pair<long long, long long> > rt;
    long long SS = b.size();
    for (long long i = 0; i < SS / 2; i++) {
      rt.push_back(b.back());
      S += b.back().second;
      b.pop_back();
    }
    ans.push_back(make_pair(0, S));
    if (inv) swap(ans.back().first, ans.back().second);
    reverse(rt.begin(), rt.end());
    a.back().second += rt[0].second;
    for (long long i = 1; i < rt.size(); i++) a.push_back(rt[i]);
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    solve2(a, b);
    return;
  }
  long long cut = 2;
  long long S = 0;
  for (long long j = 0; j < cut; j++) S += b[b.size() - j - 1].second;
  ans.push_back(make_pair(a.back().second, S));
  if (inv) {
    swap(ans.back().first, ans.back().second);
  }
  pair<long long, long long> p = a.back();
  a.pop_back();
  vector<pair<long long, long long> > rt;
  for (long long i = 0; i < cut - 1; i++) {
    pair<long long, long long> q = b.back();
    b.pop_back();
    rt.push_back(q);
  }
  pair<long long, long long> e = b.back();
  b.pop_back();
  if (a.size())
    a[a.size() - 1].second += e.second;
  else
    a.push_back(e);
  if (b.size())
    b.back().second += p.second;
  else
    b.push_back(p);
  reverse(rt.begin(), rt.end());
  for (long long i = 0; i < rt.size(); i++) a.push_back(rt[i]);
  return;
}
void solve1(vector<pair<long long, long long> > &a,
            vector<pair<long long, long long> > &b) {
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  if (a.size() == 1 && b.size() == 1) return;
  if (a.size() == 1)
    s1(a, b, false);
  else if (b.size() == 1)
    s1(b, a, true);
  if (vyh) return;
  while (true) {
    if ((long long)min(a.size(), b.size()) < 2 ||
        (long long)max(a.size(), b.size()) == 2)
      break;
    if (a.size() <= b.size())
      tr(a, b, false);
    else
      tr(b, a, true);
  }
  if (a.size() == 2 && b.size() == 2) {
    ans.push_back(
        make_pair(a.back().second, b.back().second + b[b.size() - 2].second));
    ans.push_back(make_pair(b.back().second, 0));
    return;
  }
  if (a.size() == 1)
    sv(a, b, false);
  else
    sv(b, a, true);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  vector<pair<long long, long long> > a, b;
  char symb = s[0];
  long long how = 1;
  for (long long i = 1; i < s.size(); i++) {
    if (s[i] == symb)
      how++;
    else {
      long long ind = symb - 'a';
      a.push_back(make_pair(ind, how));
      how = 1;
      symb = s[i];
    }
  }
  long long ind = symb - 'a';
  a.push_back(make_pair(ind, how));
  symb = t[0];
  how = 1;
  for (long long i = 1; i < t.size(); i++) {
    if (t[i] == symb)
      how++;
    else {
      long long ind = symb - 'a';
      b.push_back(make_pair(ind, how));
      how = 1;
      symb = t[i];
    }
  }
  ind = symb - 'a';
  b.push_back(make_pair(ind, how));
  if (a[0].first == b[0].first) {
    solve1(a, b);
  } else
    solve2(a, b);
  cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
