#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
void read(char *S, int *len, int &n, int &l) {
  scanf("%s", S + 1);
  l = strlen(S + 1);
  int cur = 0;
  n = 0;
  for (int i = 1; i <= l; i++) {
    ++cur;
    if (S[i] != S[i + 1]) len[++n] = cur, cur = 0;
  }
}
int opx, opy, ansx[N], ansy[N], ans = 1e9;
void check(char *S, char *T, int ls, int lt) {
  static int lena[N], lenb[N];
  memset(lena, 0, sizeof lena), memset(lenb, 0, sizeof lenb);
  int cur = 0, n = 0, m = 0;
  for (int i = 1; i <= ls; i++) {
    ++cur;
    if (S[i] != S[i + 1]) lena[++n] = cur, cur = 0;
  }
  for (int i = 1; i <= lt; i++) {
    ++cur;
    if (T[i] != T[i + 1]) lenb[++m] = cur, cur = 0;
  }
  if (S[1] == T[1]) {
    if (n < m) {
      for (int i = n + 1; i >= 2; i--) lena[i] = lena[i - 1];
      ++n, lena[1] = 0;
    } else {
      for (int i = m + 1; i >= 2; i--) lenb[i] = lenb[i - 1];
      ++m, lenb[1] = 0;
    }
  }
  n = max(n, m);
  if (n < ans) {
    ans = n;
    ansx[1] = opx, ansy[1] = opy;
    for (int i = 1; i <= n - 1; i++) {
      ansx[i + 1] = lena[i], ansy[i + 1] = lenb[i];
      lenb[i + 1] += lena[i], lena[i + 1] += lenb[i];
    }
  }
}
char S[N], T[N];
int lena[N], lenb[N], n, m;
char A[N], B[N];
int ln, lm;
int main() {
  read(S, lena, n, ln), read(T, lenb, m, lm);
  if (n == 1 && m == 1) {
    puts("0");
    return 0;
  }
  int il = 0, ir = 0, jl = 0, jr = 0;
  if (n < m)
    il = 0, ir = 2, jl = max(0, (m - n) / 2 - 3), jr = min(m, (m - n) / 2 + 3);
  else
    il = max(0, (n - m) / 2 - 3), ir = min(n, (n - m) / 2 + 3), jl = 0, jr = 2;
  for (int i = il; i <= ir; i++)
    for (int j = jl; j <= jr; j++) {
      opx = opy = 0;
      for (int k = 1; k <= i; k++) opx += lena[k];
      for (int k = 1; k <= j; k++) opy += lenb[k];
      int ls = opy, lt = opx;
      for (int k = 1; k <= opx; k++) B[k] = S[k];
      for (int k = 1; k <= opy; k++) A[k] = T[k];
      for (int k = opx + 1; k <= ln; k++) A[++ls] = S[k];
      for (int k = opy + 1; k <= lm; k++) B[++lt] = T[k];
      A[ls + 1] = B[lt + 1] = '\0';
      check(A, B, ls, lt);
    }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%d %d\n", ansx[i], ansy[i]);
  return 0;
}
