#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  vector<pair<int, int> > rs, rt;
  auto preprocess = [](const string& s, vector<pair<int, int> >& out) {
    int curlen = 0;
    char prev = '$';
    for (const auto& c : s) {
      if (c == prev) {
        curlen++;
        continue;
      }
      if (curlen > 0) {
        out.emplace_back(curlen, (int)(prev - 'a'));
      }
      curlen = 1;
      prev = c;
    }
    if (curlen > 0) {
      out.emplace_back(curlen, (int)(prev - 'a'));
    }
    reverse(out.begin(), out.end());
  };
  preprocess(s, rs);
  preprocess(t, rt);
  int swapped = 0;
  if ((int)rs.size() > (int)rt.size()) {
    swap(rs, rt);
    swapped = 1;
  }
  int sbegin = rs.back().second;
  for (auto& p : rs) {
    p.second = (p.second == sbegin);
  }
  for (auto& p : rt) {
    p.second = (p.second == sbegin);
  }
  vector<pair<int, int> > ans;
  auto go = [&](int spre, int tpre) {
    vector<pair<int, int> > tmps, tmpt;
    int ss = 0, st = 0;
    for (int i = 0; i < spre; i++) {
      tmps.push_back(rs.back());
      ss += rs.back().first;
      rs.pop_back();
    }
    for (int i = 0; i < tpre; i++) {
      tmpt.push_back(rt.back());
      st += rt.back().first;
      rt.pop_back();
    }
    if (swapped) {
      swap(ss, st);
    }
    ans.emplace_back(ss, st);
    while (!tmps.empty()) {
      auto p = tmps.back();
      if (!rt.empty() && p.second == rt.back().second) {
        rt.back().first += p.first;
      } else {
        rt.push_back(p);
      }
      tmps.pop_back();
    }
    while (!tmpt.empty()) {
      auto p = tmpt.back();
      if (!rs.empty() && p.second == rs.back().second) {
        rs.back().first += p.first;
      } else {
        rs.push_back(p);
      }
      tmpt.pop_back();
    }
  };
  if ((int)rs.size() == 1) {
    if (rt.back().second) {
      go(0, ((int)rt.size() / 4) * 2 + 1);
    } else {
      if ((int)rt.size() > 1) {
        go(1, ((int)rt.size() / 4) * 2 + 1);
      }
    }
  } else {
    if (rt.back().second) {
      if (((int)rt.size() - (int)rs.size()) % 4 == 3) {
        go(1, 2);
      }
      go(0, (((int)rt.size() - (int)rs.size()) / 4) * 2 + 1);
    } else {
      if (((int)rt.size() - (int)rs.size()) % 4 == 3) {
        go(1, (((int)rt.size() - (int)rs.size()) / 4) * 2 + 3);
      } else {
        go(1, (((int)rt.size() - (int)rs.size()) / 4) * 2 + 1);
      }
    }
  }
  while ((int)rs.size() > 1 || (int)rt.size() > 1) {
    go(1, 1);
  }
  cout << (int)ans.size() << endl;
  for (auto& p : ans) {
    cout << p.first << ' ' << p.second << endl;
  }
  return 0;
}
