#include <bits/stdc++.h>
using namespace std;
char s[666666], t[666666];
int n, m;
vector<int> A, B;
vector<pair<int, int> > aa;
void go(int l, int r) {
  string a, b;
  for (int i = 0; i < r; ++i) a.push_back(t[i]);
  for (int i = l; i < n; ++i) a.push_back(s[i]);
  for (int i = 0; i < l; ++i) b.push_back(s[i]);
  for (int i = r; i < m; ++i) b.push_back(t[i]);
  vector<pair<int, int> > qs;
  if (l || r) qs.push_back(pair<int, int>(l, r));
  int t = a.back(), u = b.back(), ca = a.size() - 1, cb = b.size() - 1, g = 0;
  while (1) {
    while (ca >= 0 && a[ca] == t) --ca;
    while (cb >= 0 && b[cb] == u) --cb;
    if (ca < 0 && cb < 0) break;
    if (!g)
      qs.push_back(pair<int, int>(ca + 1, cb + 1));
    else
      qs.push_back(pair<int, int>(cb + 1, ca + 1));
    ca = max(ca - 1, -1);
    cb = max(cb - 1, -1);
    g ^= 1;
    swap(t, u);
  }
  if (qs.size() < aa.size()) aa = qs;
}
void work() {
  A.clear();
  B.clear();
  for (int i = 0; i + 1 < n; ++i)
    if (s[i] != s[i + 1]) A.push_back(i);
  for (int i = 0; i + 1 < m; ++i)
    if (t[i] != t[i + 1]) B.push_back(i);
  go(0, 0);
  if (A.size()) go(A[0] + 1, 0);
  if (B.size()) go(0, B[0] + 1);
  go(n - 1, 0);
  go(0, m - 1);
  if (A.size() > B.size()) {
    int t = (A.size() - B.size()) / 2;
    for (int j = t - 2; j <= t + 2; ++j)
      if (j >= 0 && j < int(A.size())) {
        go(A[j] + 1, 0);
        if (B.size()) go(A[j] + 1, B[0] + 1);
      }
  }
  if (A.size() < B.size()) {
    int t = (B.size() - A.size()) / 2;
    for (int j = t - 2; j <= t + 2; ++j)
      if (j >= 0 && j < int(B.size())) {
        go(0, B[j] + 1);
        if (A.size()) go(A[0] + 1, B[j] + 1);
      }
  }
}
int main() {
  scanf("%s%s", s, t);
  n = strlen(s);
  m = strlen(t);
  for (int i = 1; i <= 500001; ++i) aa.push_back(pair<int, int>(0, 0));
  s[n++] = 'a';
  t[m++] = 'b';
  work();
  s[n - 1] = 'b';
  t[m - 1] = 'a';
  work();
  printf("%d\n", int(aa.size()));
  for (auto x : aa) printf("%d %d\n", x.first, x.second);
}
