#include <bits/stdc++.h>
using namespace std;
char a[2000005], b[2000005];
int lena, lenb, bega, begb, num[2000005], tot, siza, sizb, nex[2000005],
    las[2000005], col[2000005], ans, A[2000005], B[2000005];
int main() {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  lena = strlen(a + 1);
  lenb = strlen(b + 1);
  int now = 1, last = 1;
  bega = 1;
  while (last <= lena) {
    siza++;
    tot++;
    col[tot] = a[last] - 'a' + 1;
    while (a[now] == a[last]) {
      num[tot]++;
      now++;
    }
    last = now;
  }
  for (int i = 1; i < tot; i++) nex[i] = i + 1;
  for (int i = 2; i <= tot; i++) las[i] = i - 1;
  begb = tot + 1;
  now = last = 1;
  while (last <= lenb) {
    sizb++;
    tot++;
    col[tot] = b[last] - 'a' + 1;
    while (b[now] == b[last]) {
      num[tot]++;
      now++;
    }
    last = now;
  }
  for (int i = begb; i < tot; i++) nex[i] = i + 1;
  for (int i = begb + 1; i <= tot; i++) las[i] = i - 1;
  if (siza == 1 && col[bega] == col[begb] && sizb % 4 == 2) {
    ans++;
    int nw = begb;
    for (int i = 1; i <= sizb / 2; i++, nw = nex[nw]) {
      B[ans] += num[nw];
    }
    num[las[nw]] += num[bega];
    bega = begb;
    nex[las[nw]] = 0;
    begb = nw;
    las[nw] = 0;
    siza = sizb = sizb / 2;
  } else if (sizb == 1 && col[bega] == col[begb] && siza % 4 == 2) {
    ans++;
    int nw = bega;
    for (int i = 1; i <= siza / 2; i++, nw = nex[nw]) {
      A[ans] += num[nw];
    }
    num[las[nw]] += num[begb];
    begb = bega;
    nex[las[nw]] = 0;
    bega = nw;
    las[nw] = 0;
    siza = sizb = sizb / 2;
  }
  while (col[bega] == col[begb]) {
    if (siza == 1 && sizb == 1) break;
    if (siza > sizb) {
      if (siza == 2 && sizb == 1) {
        ans++;
        A[ans] = num[bega];
        B[ans] = 0;
        break;
      } else {
        siza = max(1, siza - 2);
        sizb = max(2, sizb);
        int a1 = bega, a2 = nex[a1], a3 = nex[a2];
        int b1 = begb, b2 = nex[b1];
        ans++;
        A[ans] = num[a1] + num[a2];
        B[ans] = num[b1];
        begb = a1;
        bega = b1;
        nex[a2] = nex[b2];
        num[a2] += num[b2];
        if (nex[a2]) las[nex[a2]] = a2;
        nex[b1] = nex[a3];
        num[b1] += num[a3];
        if (nex[b1]) las[nex[b1]] = b1;
      }
    } else {
      if (sizb == 2 && siza == 1) {
        ans++;
        B[ans] = num[begb];
        A[ans] = 0;
        break;
      } else {
        sizb = max(1, sizb - 2);
        siza = max(2, siza);
        int a1 = bega, a2 = nex[a1];
        int b1 = begb, b2 = nex[b1], b3 = nex[b2];
        ans++;
        A[ans] = num[a1];
        B[ans] = num[b1] + num[b2];
        begb = a1;
        bega = b1;
        nex[b2] = nex[a2];
        num[b2] += num[a2];
        if (nex[b2]) las[nex[b2]] = b2;
        nex[a1] = nex[b3];
        num[a1] += num[b3];
        if (nex[a1]) las[nex[a1]] = a1;
      }
    }
  }
  while (col[bega] != col[begb]) {
    if (siza == 1 && sizb == 1) break;
    if (siza > sizb) {
      if (siza - 3 >= sizb) {
        siza -= 3;
        sizb = max(sizb + 1, 3);
        int a1 = bega, a2 = nex[a1], a3 = nex[a2], a4 = nex[a3];
        int b1 = begb, b2 = nex[b1];
        ans++;
        A[ans] = num[a1] + num[a2] + num[a3];
        B[ans] = num[b1];
        begb = a1;
        bega = b1;
        nex[a3] = nex[b2];
        num[a3] += num[b2];
        if (nex[a3]) las[nex[a3]] = a3;
        nex[b1] = nex[a4];
        num[b1] += num[a4];
        if (nex[b1]) las[nex[b1]] = b1;
      } else {
        siza = max(1, siza - 1);
        sizb = max(1, sizb - 1);
        int a1 = bega, a2 = nex[a1];
        int b1 = begb, b2 = nex[b1];
        bega = b1;
        begb = a1;
        ans++;
        A[ans] = num[a1];
        B[ans] = num[b1];
        nex[a1] = nex[b2];
        num[a1] += num[b2];
        if (nex[a1]) las[nex[a1]] = a1;
        nex[b1] = nex[a2];
        num[b1] += num[a2];
        if (nex[b1]) las[nex[b1]] = b1;
      }
    } else {
      if (sizb - 3 >= siza) {
        sizb -= 3;
        siza = max(siza + 1, 3);
        int a1 = bega, a2 = nex[a1];
        int b1 = begb, b2 = nex[b1], b3 = nex[b2], b4 = nex[b3];
        ans++;
        A[ans] = num[a1];
        B[ans] = num[b1] + num[b2] + num[b3];
        begb = a1;
        bega = b1;
        nex[a1] = nex[b4];
        num[a1] += num[b4];
        if (nex[a1]) las[nex[a1]] = a1;
        nex[b3] = nex[a2];
        num[b3] += num[a2];
        if (nex[b3]) las[nex[b1]] = b3;
      } else {
        siza = max(1, siza - 1);
        sizb = max(1, sizb - 1);
        ans++;
        int a1 = bega, a2 = nex[a1];
        int b1 = begb, b2 = nex[b1];
        A[ans] = num[a1];
        B[ans] = num[b1];
        bega = b1;
        begb = a1;
        nex[a1] = nex[b2];
        num[a1] += num[b2];
        if (nex[a1]) las[nex[a1]] = a1;
        nex[b1] = nex[a2];
        num[b1] += num[a2];
        if (nex[b1]) las[nex[b1]] = b1;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) {
    printf("%d %d\n", A[i], B[i]);
  }
}
