#include <bits/stdc++.h>
using namespace std;
vector<pair<char, int> > prerob(string s) {
  vector<pair<char, int> > vys;
  for (int i = 0; i < s.size();) {
    int j = 0;
    while (i + j < s.size() && s[i] == s[i + j]) j++;
    pair<char, int> p;
    p.first = s[i];
    p.second = j;
    vys.push_back(p);
    i += j;
  }
  for (int i = 0; i < vys.size() / 2; i++)
    swap(vys[i], vys[vys.size() - i - 1]);
  return vys;
}
void pridaj(vector<pair<char, int> > &v, pair<char, int> &v2) {
  if (!v.empty() && v.back().first == v2.first)
    v.back().second += v2.second;
  else
    v.push_back(v2);
}
void pridajvector(vector<pair<char, int> > &v, vector<pair<char, int> > &v2) {
  for (int i = v2.size() - 1; i >= 0; i--) pridaj(v, v2[i]);
}
vector<pair<char, int> > vyber(vector<pair<char, int> > &v, int cnt) {
  vector<pair<char, int> > vys;
  while (cnt--) {
    vys.push_back(v.back());
    v.pop_back();
  }
  return vys;
}
int tl(vector<pair<char, int> > &v) {
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) cnt += v[i].second;
  return cnt;
}
vector<pair<char, int> > s1, t1;
vector<pair<int, int> > ans;
bool sw = false;
void dotaz(int ls, int lt) {
  vector<pair<char, int> > sp = vyber(s1, ls);
  vector<pair<char, int> > tp = vyber(t1, lt);
  int lens = tl(sp);
  int lent = tl(tp);
  if (sw) swap(lens, lent);
  pair<int, int> p;
  p.first = lens;
  p.second = lent;
  ans.push_back(p);
  pridajvector(s1, tp);
  pridajvector(t1, sp);
}
int main() {
  string s, t;
  cin >> s >> t;
  s1 = prerob(s);
  t1 = prerob(t);
  while (s1.size() != 1 || t1.size() != 1) {
    int ls = s1.size();
    int lt = t1.size();
    if (ls < lt) {
      swap(ls, lt);
      swap(s1, t1);
      sw = sw ^ true;
    }
    char sf = s1.back().first;
    char tf = t1.back().first;
    if (sf != tf) {
      if (lt <= 2) {
        if (ls <= 3) {
          dotaz(1, 1);
        } else {
          dotaz(3, 1);
        }
      } else
        dotaz(1, 1);
    } else {
      if (lt == 1) {
        if (ls <= 3)
          dotaz(1, 0);
        else
          dotaz(3, 0);
      } else if (lt == 2) {
        if (ls == 2)
          dotaz(1, 0);
        else
          dotaz(2, 1);
      } else
        dotaz(3, 2);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
