#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
const int N = 1000005;
int dqa, dqb, l1, l2, lc, ld;
vector<pair<int, int> > ans;
vector<int> v1, v2;
char a[N], b[N], c[N], d[N];
void ins(int a, int b) {
  ans.push_back(make_pair(a, b));
  dqa += b - a;
  dqb += a - b;
}
signed main() {
  scanf("%s%s", a, b);
  int lena = strlen(a), lenb = strlen(b);
  for (int i = 0; i < lena; i++)
    if (a[i] != a[i + 1]) v1.push_back(i + 1);
  for (int i = 0; i < lenb; i++)
    if (b[i] != b[i + 1]) v2.push_back(i + 1);
  if (a[0] == b[0]) {
    if (v1.size() == 1 && v2.size() == 1) {
      puts("1");
      cout << 0 << " " << lenb << endl;
      return 0;
    }
    if ((max(v1.size(), v2.size()) - min(v1.size(), v2.size())) % 4 == 3 &&
        min(v1.size(), v2.size()) > 1) {
      if (v1.size() > v2.size()) {
        l1 = v1[(v1.size() - v2.size() + 1) / 2 - 1];
        l2 = v2[0];
      } else {
        l1 = v1[0];
        l2 = v2[(v2.size() - v1.size() + 1) / 2 - 1];
      }
      ans.push_back(make_pair(l1, l2));
      for (int i = 0; i < l1; i++) d[ld++] = a[i];
      for (int i = 0; i < l2; i++) c[lc++] = b[i];
      for (int i = l1; i < lena; i++) c[lc++] = a[i];
      for (int i = l2; i < lenb; i++) d[ld++] = b[i];
      swap(a, c);
      swap(b, d);
      dqa = lena = lc;
      dqb = lenb = ld;
      lc = ld = 0;
      v1.clear();
      v2.clear();
      for (int i = 0; i < lena; i++)
        if (a[i] != a[i + 1]) v1.push_back(i + 1);
      for (int i = 0; i < lenb; i++)
        if (b[i] != b[i + 1]) v2.push_back(i + 1);
    }
    dqa = lena;
    dqb = lenb;
    if (v1.size() > v2.size()) {
      l1 = v1[(v1.size() - v2.size()) / 2 +
              (((v1.size() - v2.size()) / 2) % 2 == 0) - 1];
      l2 = 0;
    } else {
      l1 = 0;
      l2 = v2[(v2.size() - v1.size()) / 2 +
              (((v2.size() - v1.size()) / 2) % 2 == 0) - 1];
    }
  } else {
    if (v1.size() == 1 && v2.size() == 1) {
      puts("0");
      return 0;
    }
    if (v1.size() > v2.size()) {
      l1 = v1[(v1.size() - v2.size() + 1) / 2 +
              (((v1.size() - v2.size() + 1) / 2) % 2 == 0) - 1];
      l2 = v2[0];
    } else {
      l1 = v1[0];
      l2 = v2[(v2.size() - v1.size() + 1) / 2 +
              (((v2.size() - v1.size() + 1) / 2) % 2 == 0) - 1];
    }
  }
  ans.push_back(make_pair(l1, l2));
  for (int i = 0; i < l1; i++) d[ld++] = a[i];
  for (int i = 0; i < l2; i++) c[lc++] = b[i];
  for (int i = l1; i < lena; i++) c[lc++] = a[i];
  for (int i = l2; i < lenb; i++) d[ld++] = b[i];
  swap(a, c);
  swap(b, d);
  dqa = lena = lc;
  dqb = lenb = ld;
  v1.clear();
  v2.clear();
  for (int i = 0; i < lena; i++)
    if (a[i] != a[i + 1]) v1.push_back(i + 1);
  for (int i = 0; i < lenb; i++)
    if (b[i] != b[i + 1]) v2.push_back(i + 1);
  if (v1.size() < v2.size())
    v1.resize(v2.size());
  else
    v2.resize(v1.size());
  for (unsigned i = 0; i < v1.size(); i++)
    if (!v1[i]) v1[i] = v1[i - 1];
  for (unsigned i = 0; i < v2.size(); i++)
    if (!v2[i]) v2[i] = v2[i - 1];
  for (unsigned i = 0; i + 1 < v1.size(); i++)
    ins(v1[i] + dqa - lena, v2[i] + dqb - lenb);
  writeln(ans.size());
  for (unsigned i = 0; i < ans.size(); i++) {
    write(ans[i].first);
    putchar(' ');
    writeln(ans[i].second);
  }
}
