#include <bits/stdc++.h>
using namespace std;
char s[200009], t[200009];
deque<int> a1, a2, q1, q2, tm;
int i, c, f, f1, f2, x, y, z, u1, u2;
int main() {
  for (scanf("%s%s", s, t), c = 1, f1 = (s[0] == t[0]); s[i]; ++c, ++i)
    if (s[i] != s[i + 1]) q1.push_back(c), c = 0;
  for (f = i, c = 1, i = 0; t[i]; ++c, ++i)
    if (t[i] != t[i + 1]) q2.push_back(c), c = 0;
  f2 = (s[f - 1] == t[i - 1]), f = 0, u1 = q1.size(), u2 = q2.size();
  if (u1 == 1 && u2 == 1) printf("0\n"), exit(0);
  if (u1 < u2) f = 1, swap(u1, u2), swap(q1, q2);
  if (u2 == 1)
    f2 ? (++u2, f2 = 0, q2.push_back(0)) : (++u2, f1 = !f1, q2.push_front(0));
  if (f1) {
    for (; u1 > u2; u1 -= 2)
      x = q1.front(), q1.pop_front(), y = q1.front(), q1.pop_front(),
      a1.push_back(x + y), a2.push_back(z = q2.front()), q1.front() += z,
      q2.pop_front(), q2.front() += y, q2.push_front(x);
    ++u1, q1.push_front(0);
    if (f2) ++u2, q2.push_back(0);
  } else {
    for (; u1 > u2 + 2; u1 -= 3, ++u2)
      x = q1.front(), q1.pop_front(), y = q1.front(), q1.pop_front(),
      z = q1.front(), q1.pop_front(), a1.push_back(x + y + z),
      a2.push_back(c = q2.front()), q1.front() += c, q2.pop_front(),
      q2.front() += z, q2.push_front(y), q2.push_front(x);
    while (u1 < u2) ++u1, q1.push_back(0);
    while (u2 < u1) ++u2, q2.push_back(0);
  }
  while (--u1)
    a1.push_back(x = q1.front()), a2.push_back(y = q2.front()), q1.pop_front(),
        q2.pop_front(), q2.front() += x, q1.front() += y;
  for (printf("%d\n", a1.size()), f ? swap(a1, a2) : (void)0; !a1.empty();)
    printf("%d %d\n", a1.front(), a2.front()), a1.pop_front(), a2.pop_front();
  exit(0);
}
