#include <bits/stdc++.h>
using namespace std;
string s, t;
int p = 0, q = 0;
int lp = 0, lq = 0;
int ls, lt, ks, kt;
vector<int> a, b;
void sw(int a0, int b0) {
  a.push_back(a0 + lp + 1);
  b.push_back(b0 + lq + 1);
  swap(lp, lq);
  lp += b0 - a0;
  lq += a0 - b0;
}
void init() {
  ls = s.length(), lt = t.length();
  ks = 0, kt = 0;
  for (int i = 0; i < ls - 1; ++i) {
    if (s[i] != s[i + 1]) ++ks;
  }
  for (int i = 0; i < lt - 1; ++i) {
    if (t[i] != t[i + 1]) ++kt;
  }
}
void move_half() {
  int hks = (ks + 1) / 2, hkt = (kt + 1) / 2;
  for (int i = 0; i < ls - 1; ++i) {
    if (s[i] != s[i + 1]) --hks;
    if (hks == 0) {
      if (ks > 0) hks = i + 1;
      break;
    }
  }
  for (int i = 0; i < lt - 1; ++i) {
    if (t[i] != t[i + 1]) --hkt;
    if (hkt == 0) {
      if (kt > 0) hkt = i + 1;
      break;
    }
  }
  if (s[hks] == t[hkt]) {
    if ((ks % 2 == 0) || (kt % 2 == 1 && ks >= kt)) {
      while (s[hks] == s[hks + 1]) ++hks;
      ++hks;
    } else {
      while (t[hkt] == t[hkt + 1]) ++hkt;
      ++hkt;
    }
  }
  string temp = s.substr(0, hks) + t.substr(hkt, lt - hkt);
  s = t.substr(0, hkt) + s.substr(hks, ls - hks);
  t = temp;
  a.push_back(hks);
  b.push_back(hkt);
  init();
  return;
}
int main() {
  cin >> s >> t;
  init();
  if (abs(ks - kt) >= 2) {
    move_half();
  }
  while (p < ls - 1 || q < lt - 1) {
    while (p < ls - 1 && s[p] == s[p + 1]) ++p;
    while (q < lt - 1 && t[q] == t[q + 1]) ++q;
    if (p >= ls - 1 && q >= lt - 1) break;
    char c1 = s[p], c2 = t[q];
    if (p == ls || q == lt || c1 != c2) {
      if (p == ls) --p;
      if (q == lt) --q;
      sw(p, q);
      ++p, ++q;
      if (ks > 0) --ks;
      if (kt > 0) --kt;
    } else {
      if (q >= lt - 1 || ks > kt) {
        sw(p, -1);
        ++p;
        if (ks > 0) --ks;
      } else {
        sw(-1, q);
        ++q;
        if (kt > 0) --kt;
      }
    }
  }
  int n = a.size();
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    printf("%d %d\n", a[i], b[i]);
  }
  return 0;
}
