#include <bits/stdc++.h>
using namespace std;
string s, t;
vector<pair<char, int> > s1;
vector<pair<char, int> > s2;
vector<pair<int, int> > sol;
bool z = 0;
int dulj(vector<pair<char, int> > v) {
  int out = 0;
  for (int i = 0; i < v.size(); i++) out += v[i].second;
  return out;
}
void dodaj(vector<pair<char, int> > &v, vector<pair<char, int> > d) {
  for (int i = d.size() - 1; i >= 0; i--) {
    if (!v.empty() && v.back().first == d[i].first) {
      v.back().second += d[i].second;
    } else {
      v.push_back(d[i]);
    }
  }
}
vector<pair<char, int> > makni(vector<pair<char, int> > &vec, int kol) {
  vector<pair<char, int> > tren;
  tren.clear();
  while (kol--) {
    tren.push_back(vec.back());
    vec.pop_back();
  }
  return tren;
}
int main() {
  cin >> s >> t;
  int sad = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] != s[i + 1]) {
      s1.push_back({s[i], sad + 1});
      sad = 0;
    } else {
      sad++;
    }
  }
  s1.push_back({s[s.size() - 1], sad + 1});
  sad = 0;
  for (int i = 0; i < t.size() - 1; i++) {
    if (t[i] != t[i + 1]) {
      s2.push_back({t[i], sad + 1});
      sad = 0;
    } else {
      sad++;
    }
  }
  s2.push_back({t[t.size() - 1], sad + 1});
  sad = 0;
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  auto query = [&](int l1, int l2) {
    auto dio1 = makni(s1, l1);
    auto dio2 = makni(s2, l2);
    int len1 = dulj(dio1);
    int len2 = dulj(dio2);
    if (z) {
      swap(len1, len2);
    }
    sol.push_back(make_pair(len1, len2));
    dodaj(s1, dio2);
    dodaj(s2, dio1);
  };
  while (s1.size() != 1 || s2.size() != 1) {
    int poc1 = s1.size();
    int poc2 = s2.size();
    if (poc1 < poc2) {
      swap(poc1, poc2);
      swap(s1, s2);
      z ^= 1;
    }
    char ch1 = s1.back().first;
    char ch2 = s2.back().first;
    if (ch1 != ch2) {
      if (poc2 <= 2) {
        if (poc1 <= 3) {
          query(1, 1);
        } else {
          query(3, 1);
        }
      } else {
        query(1, 1);
      }
    } else {
      if (poc2 == 1) {
        if (poc1 <= 3) {
          query(1, 0);
        } else {
          query(3, 0);
        }
      } else if (poc2 == 2) {
        if (poc1 == 2) {
          query(1, 0);
        } else {
          query(2, 1);
        }
      } else {
        query(3, 2);
      }
    }
  }
  cout << sol.size() << "\n";
  for (int i = 0; i < sol.size(); i++)
    cout << sol[i].first << " " << sol[i].second << "\n";
  return 0;
}
