#include <bits/stdc++.h>
using namespace std;
string S;
bool invers;
deque<pair<char, int> > A, B;
vector<pair<int, int> > ans;
deque<pair<char, int> > Transformare(string S) {
  deque<pair<char, int> > sir;
  for (int i = 0; i < S.size(); ++i) {
    int j = i;
    while (j < S.size() - 1 && S[j + 1] == S[i]) {
      ++j;
    }
    sir.push_back({S[i], j - i + 1});
    i = j;
  }
  return sir;
}
void Read() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> S;
  A = Transformare(S);
  cin >> S;
  B = Transformare(S);
}
void Schimb(int ElementeA, int ElementeB) {
  deque<pair<char, int> > aux_A, aux_B;
  int size_A = 0, size_B = 0;
  for (int i = 0; i < ElementeA; ++i) {
    aux_A.push_back(A.front());
    size_A += A.front().second;
    A.pop_front();
  }
  for (int i = 0; i < ElementeB; ++i) {
    aux_B.push_back(B.front());
    size_B += B.front().second;
    B.pop_front();
  }
  if (invers) {
    swap(size_A, size_B);
  }
  ans.push_back({size_A, size_B});
  while (!aux_B.empty()) {
    if (A.front().first == aux_B.back().first)
      A.front().second += aux_B.back().second;
    else
      A.push_front(aux_B.back());
    aux_B.pop_back();
  }
  while (!aux_A.empty()) {
    if (B.front().first == aux_A.back().first)
      B.front().second += aux_A.back().second;
    else
      B.push_front(aux_A.back());
    aux_A.pop_back();
  }
}
void Solve() {
  invers = 0;
  while (A.size() > 1 || B.size() > 1) {
    int N = A.size();
    int M = B.size();
    if (N < M) {
      swap(N, M);
      swap(A, B);
      invers ^= 1;
    }
    char a = A.front().first;
    char b = B.front().first;
    if (a != b) {
      if (M <= 2) {
        if (N <= 3) {
          Schimb(1, 1);
        } else {
          Schimb(3, 1);
        }
      } else
        Schimb(1, 1);
    } else {
      if (M == 1) {
        if (N <= 3) {
          Schimb(1, 0);
        } else
          Schimb(3, 0);
      } else if (M == 2) {
        if (N == 2) {
          Schimb(1, 0);
        } else
          Schimb(2, 1);
      } else
        Schimb(3, 2);
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].first << " " << ans[i].second << '\n';
  }
}
int main() {
  Read();
  Solve();
  return 0;
}
