#include <bits/stdc++.h>
using namespace std;
const int N = 44;
bool vis[N][N][2];
int f[N][N][2], p1[N][N][2], p2[N][N][2];
int s1[N], s2[N];
void update(int& f, int& p1, int& p2, int val, int sl, int sr) {
  if (val < f || (val == f && (sl + sr < p1 + p2))) f = val, p1 = sl, p2 = sr;
}
int dp(int l, int r, int dif) {
  if (!l || !r) return 0x7f7f7f7f;
  if (l == 1 && r == 1) return (dif == 1) ? (0) : (0x7f7f7f7f);
  if (vis[l][r][dif]) return f[l][r][dif];
  vis[l][r][dif] = true;
  for (int sl = 0; sl <= l; sl++)
    for (int sr = 0; sr <= r; sr++) {
      if (!sl && !sr) continue;
      for (int i = 0; i < sr; i++) s1[i] = (dif + i) & 1;
      s1[sr] = sl & 1;
      for (int i = 0; i < sl; i++) s2[i] = i & 1;
      s2[sl] = (dif + sr) & 1;
      int red1 = 0, red2 = 0;
      for (int i = 1; i <= sr && i < l - sl + sr; i++)
        red1 += (s1[i] == s1[i - 1]);
      for (int i = 1; i <= sl && i < r + sl - sr; i++)
        red2 += (s2[i] == s2[i - 1]);
      if (!red1 && !red2) continue;
      update(f[l][r][dif], p1[l][r][dif], p2[l][r][dif],
             dp(l + sr - sl - red1, r + sl - sr - red2, s1[0] != s2[0]) + 1, sl,
             sr);
    }
  return f[l][r][dif];
}
typedef class Node {
 public:
  Node* suf;
  int col, s;
  Node() {}
  Node(Node* suf, int col, int s) : suf(suf), col(col), s(s) {}
} Node;
int d;
int l = 1, r = 1;
Node *stl, *str;
Node nl[200005], nr[200005];
char buf[200005];
inline void init() {
  int c1, c2;
  scanf("%s", buf);
  c1 = buf[0];
  nl[0] = Node(nl + 1, -1, -233333);
  nl[1] = Node(nl + 2, c1, 1);
  for (int i = 1; buf[i]; i++)
    if (buf[i] == buf[i - 1])
      nl[l].s++;
    else
      l += 1, nl[l] = Node(nl + l + 1, buf[i], 1);
  nl[l + 1].s = -1;
  scanf("%s", buf);
  c2 = buf[0];
  nr[0] = Node(nr + 1, -1, -233333);
  nr[1] = Node(nr + 2, c2, 1);
  for (int i = 1; buf[i]; i++)
    if (buf[i] == buf[i - 1])
      nr[r].s++;
    else
      r += 1, nr[r] = Node(nr + r + 1, buf[i], 1);
  nr[r + 1].s = -1;
  d = (c1 != c2);
  stl = nl, str = nr;
}
pair<int, int> swapS(int sl, int sr, int& l, int& r) {
  Node *pl = stl, *psl, *pr = str, *psr;
  int rl = 0, rr = 0;
  for (int i = 0; i < sl; i++) pl = pl->suf, rl += pl->s;
  for (int i = 0; i < sr; i++) pr = pr->suf, rr += pr->s;
  psl = pl->suf, psr = pr->suf;
  swap(stl, str);
  pl->suf = psr;
  pr->suf = psl;
  if (pl->s > 0 && psr->s > 0 && pl->col == psr->col) {
    pl->s += psr->s;
    pl->suf = psr->suf;
    r--;
  }
  if (pr->s > 0 && psl->s > 0 && pr->col == psl->col) {
    pr->s += psl->s;
    pr->suf = psl->suf;
    l--;
  }
  return pair<int, int>(rl, rr);
}
pair<int, int> st1[4] = {pair<int, int>(1, 0), pair<int, int>(2, 1),
                         pair<int, int>(3, 0), pair<int, int>(1, 0)};
pair<int, int> st2[4] = {pair<int, int>(1, 0), pair<int, int>(2, 1),
                         pair<int, int>(0, 1), pair<int, int>(1, 0)};
pair<int, int> st3[4] = {pair<int, int>(0, 1), pair<int, int>(0, 3),
                         pair<int, int>(0, 3), pair<int, int>(0, 1)};
pair<int, int> st4[4] = {pair<int, int>(1, 1), pair<int, int>(2, 0),
                         pair<int, int>(3, 1), pair<int, int>(1, 1)};
pair<int, int> st5[4] = {pair<int, int>(1, 1), pair<int, int>(3, 1),
                         pair<int, int>(3, 1), pair<int, int>(1, 1)};
pair<int, int> st6[4] = {pair<int, int>(0, 2), pair<int, int>(1, 3),
                         pair<int, int>(1, 3), pair<int, int>(1, 1)};
pair<int, int> g(int x, int y, int d) {
  if (x <= 10 && y <= 10) {
    dp(x, y, d);
    return pair<int, int>(p1[x][y][d], p2[x][y][d]);
  }
  if (!d) {
    if (y == 1) return st1[x % 4];
    if (y == 2) return st2[x % 4];
    if (x == 1) return st3[y % 4];
    if (x == 2)
      return (y % 4 == 1) ? (pair<int, int>(1, 2)) : (pair<int, int>(0, 1));
    return ((((x - y) % 4 + 4) % 4) == 1) ? (pair<int, int>(1, 0))
                                          : (pair<int, int>(0, 1));
  } else {
    if (y == 1) return st4[x % 4];
    if (y == 2) return st5[x % 4];
    if (x == 1)
      return (y % 4 == 2) ? (pair<int, int>(1, 3)) : (pair<int, int>(0, 2));
    if (x == 2) return st6[y % 4];
    return ((((x - y) % 4 + 4) % 4) == 2) ? (pair<int, int>(0, 2))
                                          : (pair<int, int>(1, 1));
  }
}
vector<pair<int, int> > opt;
inline void solve() {
  memset(vis, false, sizeof(vis));
  memset(f, 0x7f, sizeof(f));
  while (l > 1 || r > 1) {
    pair<int, int> s = g(l, r, d);
    int sl = s.first, sr = s.second;
    l = l - sl + sr, r = r + sl - sr;
    opt.push_back(swapS(sl, sr, l, r));
    d = (stl->suf->col != str->suf->col);
  }
  printf("%d\n", (signed)opt.size());
  for (int i = 0; i < (signed)opt.size(); i++)
    printf("%d %d\n", opt[i].first, opt[i].second);
}
int main() {
  init();
  solve();
  return 0;
}
