#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
  return x;
}
const int N = 1000005;
int c[N], v[N], Next[N], cnt_node = 0;
int L = 0, R = 1, len[2], head[2], n = 0, ans[N][2];
char s1[N], s2[N];
int new_node(int color, int tot, int nxt) {
  cnt_node++, c[cnt_node] = color, v[cnt_node] = tot, Next[cnt_node] = nxt;
  return cnt_node;
}
void build(int f, char s[]) {
  int n = strlen(s + 1), p = new_node(s[1] - 'a', 1, 0);
  head[f] = p, len[f] = 1;
  for (int i = 2; i <= n; i++)
    if (s[i] == s[i - 1])
      v[p]++;
    else
      p = Next[p] = new_node(s[i] - 'a', 1, 0), len[f]++;
}
int func0(int x, int a, int b) { return abs(a - 2 * x - 1 - (b + 2 * x)); }
int func1(int x, int a, int b) { return abs((a - 2 * x) - (b + 2 * x - 2)); }
int func2(int x, int a, int b) { return abs(a - 2 * x - 1 - (b + 2 * x - 1)); }
void Get_len() {
  len[L] = 0, len[R] = 0;
  for (int p = head[L]; p; p = Next[p]) len[L]++;
  for (int p = head[R]; p; p = Next[p]) len[R]++;
  if (len[L] < len[R]) swap(L, R);
}
int main() {
  scanf("%s%s", s1 + 1, s2 + 1);
  build(0, s1), build(1, s2);
  if (len[L] < len[R]) swap(L, R);
  while (len[L] > 1) {
    if (len[L] < len[R]) swap(L, R);
    if (c[head[L]] == c[head[R]]) {
      if (len[R] > 1 && len[L] > 2) {
        int a = len[L], b = len[R], x1 = (a - b + 2) / 4, x2 = x1 + 1;
        int x = func1(x1, a, b) <= func1(x2, a, b) ? x1 : x2;
        x = max(1, min(x, a / 2));
        int tot = v[head[L]], p = head[L];
        for (int i = 1; i <= x * 2 - 1; i++) p = Next[p], tot += v[p];
        n++, ans[n][L] = tot, ans[n][R] = v[head[R]];
        int hL = head[L], hR = head[R];
        v[head[L] = Next[p]] += v[hR];
        head[R] = hL, Next[p] = Next[Next[hR]], v[p] += v[Next[hR]];
        len[L] -= x * 2;
        len[R] += x * 2 - 2;
        if (len[L] < len[R]) swap(L, R);
        continue;
      }
      int a = len[L], b = len[R], x1 = (a - b - 1) / 4, x2 = x1 + 1;
      int x = func0(x1, a, b) <= func0(x2, a, b) ? x1 : x2;
      x = min(x, (a - 1) / 2);
      int tot = v[head[L]], p = head[L];
      for (int i = 1; i <= x * 2; i++) p = Next[p], tot += v[p];
      n++, ans[n][L] = tot, ans[n][R] = 0;
      int t = Next[p];
      Next[p] = head[R];
      head[R] = head[L];
      head[L] = t;
      v[p] += v[Next[p]];
      Next[p] = Next[Next[p]];
      Get_len();
    } else {
      int a = len[L], b = len[R], x1 = (a - b - 1) / 4, x2 = x1 + 1;
      int x = func2(x1, a, b) <= func2(x2, a, b) ? x1 : x2;
      x = min(x, (a - 1) / 2);
      int tot = v[head[L]], p = head[L];
      for (int i = 1; i <= x * 2; i++) p = Next[p], tot += v[p];
      n++, ans[n][L] = tot, ans[n][R] = v[head[R]];
      int hL = head[L], hR = head[R];
      head[R] = hL, head[L] = hR;
      v[head[L]] += v[Next[p]];
      v[p] += v[Next[hR]];
      int t = Next[Next[hR]];
      Next[head[L]] = Next[Next[p]];
      Next[p] = t;
      Get_len();
    }
    while (c[head[L]] != c[head[R]] && len[R] > 1) {
      int hL = head[L], hR = head[R];
      n++, ans[n][L] = v[hL], ans[n][R] = v[hR];
      head[L] = hR, head[R] = hL;
      v[hL] += v[Next[hR]];
      v[hR] += v[Next[hL]];
      int nhL = Next[Next[hL]], nhR = Next[Next[hR]];
      Next[hL] = nhR, Next[hR] = nhL;
      len[L]--, len[R]--;
    }
  }
  printf("%d\n", n);
  for (int i = 1; i <= n; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
