#include <bits/stdc++.h>
using namespace std;
char s[202020], t[202020];
int s1, t1;
int sl, tl;
int a[2020202], a1, an;
int b[2020202], b1, bn;
int cnt = 0;
int ans1[505050], ans2[505050];
void work1();
void work2();
void work1() {
  if (an - a1 + 1 >= 4 && bn - b1 + 1 == 1) {
    cnt++;
    ans1[cnt] = a[a1] + a[a1 + 1] + a[a1 + 2];
    ans2[cnt] = 0;
    b[b1] += a[a1 + 2];
    b[b1 - 1] = a[a1 + 1];
    b[b1 - 2] = a[a1];
    a1 += 3;
    b1 -= 2;
    work2();
  }
  if (an - a1 + 1 == 1 && bn - b1 + 1 >= 4) {
    cnt++;
    ans1[cnt] = 0;
    ans2[cnt] = b[b1] + b[b1 + 1] + b[b1 + 2];
    a[a1] += b[b1 + 2];
    a[a1 - 1] = b[b1 + 1];
    a[a1 - 2] = b[b1];
    a1 -= 2;
    b1 += 3;
    work2();
  }
  if (an - a1 + 1 >= 3 && an - a1 + 1 > bn - b1 + 1) {
    cnt++;
    ans1[cnt] = a[a1] + a[a1 + 1];
    ans2[cnt] = b[b1];
    a[a1 + 2] += b[b1];
    if (b1 + 1 <= bn)
      b[b1 + 1] += a[a1 + 1];
    else {
      bn++;
      b[bn] = a[a1 + 1];
    }
    b[b1] = a[a1];
    a1 += 2;
    work1();
  } else if (bn - b1 + 1 >= 3) {
    cnt++;
    ans1[cnt] = a[a1];
    ans2[cnt] = b[b1] + b[b1 + 1];
    b[b1 + 2] += a[a1];
    if (a1 + 1 <= an)
      a[a1 + 1] += b[b1 + 1];
    else {
      an++;
      a[an] = b[b1 + 1];
    }
    a[a1] = b[b1];
    b1 += 2;
    work1();
  } else if (an - a1 + 1 == 2 && bn - b1 + 1 == 2) {
    cnt++;
    ans1[cnt] = a[a1] + a[a1 + 1];
    ans2[cnt] = b[b1];
    a[a1 + 2] = b[b1];
    b[b1 + 1] += a[a1 + 1];
    b[b1] = a[a1];
    a1 += 2;
    an++;
    work1();
  } else if (an - a1 + 1 == 2) {
    cnt++;
    ans1[cnt] = a[a1];
    ans2[cnt] = 0;
  } else if (bn - b1 + 1 == 2) {
    cnt++;
    ans1[cnt] = 0;
    ans2[cnt] = b[b1];
  }
}
void work2() {
  if (an - a1 + 1 > 4) {
    ++cnt;
    ans1[cnt] = a[a1] + a[a1 + 1] + a[a1 + 2];
    ans2[cnt] = b[b1];
    a[a1 + 3] += b[b1];
    if (b1 + 1 <= bn)
      b[b1 + 1] += a[a1 + 2];
    else {
      ++bn;
      b[bn] = a[a1 + 2];
    }
    b[b1] = a[a1 + 1];
    b[b1 - 1] = a[a1];
    b1--;
    a1 += 3;
    work2();
  } else if (bn - b1 + 1 > 4) {
    ++cnt;
    ans1[cnt] = a[a1];
    ans2[cnt] = b[b1] + b[b1 + 1] + b[b1 + 2];
    b[b1 + 3] += a[a1];
    if (a1 + 1 <= an)
      a[a1 + 1] += b[b1 + 2];
    else {
      an++;
      a[an] = b[b1 + 2];
    }
    a[a1] = b[b1 + 1];
    a[a1 - 1] = b[b1];
    a1--;
    b1 += 3;
    work2();
  } else if (bn - b1 + 1 > 1 || an - a1 + 1 > 1) {
    cnt++;
    ans1[cnt] = a[a1];
    ans2[cnt] = b[b1];
    if (a1 + 1 <= an)
      a[a1 + 1] += b[b1];
    else {
      an++;
      a[an] = b[b1];
    }
    if (b1 + 1 <= bn)
      b[b1 + 1] += a[a1];
    else {
      bn++;
      b[bn] = a[a1];
    }
    a1++;
    b1++;
    work2();
  }
}
int main() {
  int len = 0;
  scanf("%s%s", s, t);
  sl = strlen(s);
  tl = strlen(t);
  s1 = s[0] - 'a';
  t1 = t[0] - 'a';
  len = 1;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  an = 1000000;
  for (int i = 1; i < sl; i++)
    if (s[i] != s[i - 1]) {
      a[++an] = len;
      len = 1;
    } else
      len++;
  a[++an] = len;
  len = 1;
  bn = 1000000;
  for (int i = 1; i < tl; i++)
    if (t[i] != t[i - 1]) {
      b[++bn] = len;
      len = 1;
    } else
      len++;
  b[++bn] = len;
  a1 = b1 = 1000001;
  if (s1 == t1)
    work1();
  else
    work2();
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans1[i], ans2[i]);
  return 0;
}
