#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
inline int qpow(int x, int e, int _MOD) {
  int ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % _MOD;
    x = x * x % _MOD;
    e >>= 1;
  }
  return ans;
}
char sa[200005], sb[200005];
vector<pair<int, int> > a, b;
inline void push(vector<pair<int, int> > &v, pair<int, int> add) {
  if (v.empty())
    v.push_back(add);
  else {
    if (v.back().first == add.first)
      v.back().second += add.second;
    else
      v.push_back(add);
  }
}
bool swp = 0;
vector<pair<int, int> > ans;
inline void deal(int len) {
  pair<int, int> bk = b.back();
  b.pop_back();
  int sum = 0;
  for (int i = len; i >= 1; i--)
    push(b, a[a.size() - i]), sum += a[a.size() - i].second;
  for (int i = len; i >= 1; i--) a.pop_back();
  ans.push_back({sum, bk.second});
  push(a, bk);
}
signed main() {
  cin >> sa + 1 >> sb + 1;
  int la = strlen(sa + 1), lb = strlen(sb + 1);
  for (int i = la; i >= 1; i--) push(a, {sa[i] - 'a', 1});
  for (int i = lb; i >= 1; i--) push(b, {sb[i] - 'a', 1});
  if (a.size() < b.size()) swap(a, b), swp = 1;
  if (a.back().first == b.back().first) {
    if ((a.size() - b.size()) % 4 == 3) deal((a.size() - b.size() + 1) / 4 * 2);
    b.push_back({((b.back().first == 0) ? (1) : (0)), 0});
    deal((a.size() - b.size() + 1) / 4 * 2 + 1);
  } else {
    if (a.size() - b.size() > 2) deal((a.size() - b.size() + 1) / 4 * 2 + 1);
  }
  while (a.size() > 1 || b.size() > 1) {
    deal(1);
  }
  cout << ans.size() << endl;
  for (__typeof(ans.begin()) it = ans.begin(); it != ans.end(); it++) {
    if (swp)
      cout << (it->second) << " " << (it->first) << endl;
    else
      cout << (it->first) << " " << (it->second) << endl;
  }
  return 0;
}
