#include <bits/stdc++.h>
using namespace std;
void compute(deque<pair<char, int> > ds, deque<pair<char, int> > dt,
             vector<array<int, 2> > &ans, int flg) {
  int swp = 0;
  int totlens = 0;
  int totlent = 0;
  for (auto x : ds) {
    totlens += x.second;
  }
  for (auto x : dt) {
    totlent += x.second;
  }
  auto perform = [&](int blks, int blkt) {
    int lens = 0, lent = 0;
    vector<pair<char, int> > vs, vt;
    for (int i = 0; i < blks; i++) {
      vs.push_back(ds.front());
      lens += ds[0].second;
      ds.pop_front();
    }
    for (int i = 0; i < blkt; i++) {
      vt.push_back(dt.front());
      lent += dt[0].second;
      dt.pop_front();
    }
    if (flg) {
      if (swp)
        ans.push_back({totlent - lent, totlens - lens});
      else
        ans.push_back({totlens - lens, totlent - lent});
    } else {
      if (swp)
        ans.push_back({lent, lens});
      else
        ans.push_back({lens, lent});
    }
    totlent = totlent - lent + lens;
    totlens = totlens - lens + lent;
    while (!vt.empty()) {
      if (ds.empty() || ds.front().first != vt.back().first)
        ds.push_front(vt.back());
      else
        ds.front().second += vt.back().second;
      vt.pop_back();
    }
    while (!vs.empty()) {
      if (dt.empty() || dt.front().first != vs.back().first)
        dt.push_front(vs.back());
      else
        dt.front().second += vs.back().second;
      vs.pop_back();
    }
  };
  if (ds[0].first == dt[0].first) {
    if (ds.size() > dt.size()) {
      swap(totlens, totlent);
      swap(ds, dt);
      swp ^= 1;
    }
    int r = (int(dt.size()) - int(ds.size())) / 2;
    if (r & 1)
      perform(0, r);
    else
      perform(0, r + 1);
  }
  while (ds.size() > 1 || dt.size() > 1) {
    if (ds.size() > dt.size()) {
      swap(totlens, totlent);
      swap(ds, dt);
      swp ^= 1;
    }
    if (ds.size() == 1) {
      if (dt.size() == 2) {
        perform(1, 1);
        return;
      }
      if (dt.size() == 3) {
        perform(1, 1);
        perform(1, 1);
        return;
      }
      perform(1, 3);
    } else if (dt.size() <= 3) {
      perform(1, 1);
    } else if (ds.size() == 2) {
      perform(1, 3);
    } else {
      perform(1, 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  string s, t;
  cin >> s >> t;
  deque<pair<char, int> > ds;
  deque<pair<char, int> > dt;
  for (auto ch : s) {
    if (ds.empty() || ds.back().first != ch)
      ds.push_back({ch, 1});
    else
      ds.back().second++;
  }
  for (auto ch : t) {
    if (dt.empty() || dt.back().first != ch)
      dt.push_back({ch, 1});
    else
      dt.back().second++;
  }
  vector<array<int, 2> > ans;
  if (ds.front().first != dt.front().first) {
    compute(ds, dt, ans, false);
  } else if (ds.back().first != dt.back().first) {
    reverse(ds.begin(), ds.end());
    reverse(dt.begin(), dt.end());
    compute(ds, dt, ans, true);
    for (int i = 1; i < ans.size(); i += 2) {
      swap(ans[i][0], ans[i][1]);
    }
  } else {
    compute(ds, dt, ans, false);
  }
  cout << ans.size() << '\n';
  for (auto x : ans) {
    cout << x[0] << " " << x[1] << '\n';
  }
  return 0;
}
