#include <bits/stdc++.h>
using namespace std;
using pi = pair<bool, int>;
using dp = deque<pi>;
using dpt = dp::iterator;
const int ML = 2e5 + 100;
char I[ML];
void in(bool* s, dp& u, int& S) {
  scanf(" %s", I);
  for (S = 0; I[S] != '\0'; S++) {
    s[S] = I[S] == 'b';
    if (not u.empty() and u.back().first == s[S])
      u.back().second++;
    else
      u.push_back({s[S], 1});
  }
}
void flip(dp& a, dp& b, int A, int B) {
  assert(A <= a.size() and B <= b.size());
  dp c, d;
  for (int i = 0; i < A; i++) c.push_back(a.front()), a.pop_front();
  for (int i = 0; i < B; i++) d.push_back(b.front()), b.pop_front();
  for (int i = 0; i < A; i++)
    (b.empty() or b.front().first != c.back().first ? b.push_front(c.back()),
     0 : b.front().second += c.back().second),
        c.pop_back();
  for (int i = 0; i < B; i++)
    (a.empty() or a.front().first != d.back().first ? a.push_front(d.back()),
     0 : a.front().second += d.back().second),
        d.pop_back();
  assert(c.empty() and d.empty());
}
using i2 = array<int, 2>;
const int MN = 5e5 + 100;
i2 f[MN];
int N;
void add(int a, int b) { f[N++] = {a, b}; }
void fin() {
  printf("%d\n", N);
  for (int i = 0; i < N; i++) printf("%d %d\n", f[i][0], f[i][1]);
}
bool s[ML], t[ML];
dp u, v;
int S, T, A, B, C;
void greedy() {
  if (u.front().first == v.front().first) {
    if (u.size() < v.size())
      add(0, v.front().second), u.front().second += v.front().second,
          v.pop_front();
    else
      add(u.front().second, 0), v.front().second += u.front().second,
          u.pop_front();
  }
  A = B = 0;
  int i = 1;
  if (u.size() < v.size())
    for (dpt a = u.begin(), b = v.begin(); i < v.size();
         i++, b++, (a != u.end() ? a++ : a))
      add(A += (a != u.end() ? a->second : 0), B += b->second), swap(A, B);
  else
    for (dpt a = u.begin(), b = v.begin(); i < u.size();
         i++, a++, (b != v.end() ? b++ : b))
      add(A += a->second, B += (b != v.end() ? b->second : 0)), swap(A, B);
}
int F, X, Y, L;
void rp(int a, int b, int c) {
  if (a < F) F = a, X = b, Y = c;
}
void pick(const dp& a, const dp& b) {
  F = max(u.size() - 1, v.size() - 1) +
      (u.size() == v.size() and u.front().first == v.front().first),
  X = Y = -1;
  if (a.front().first == b.front().first) {
    if (a.size() < b.size()) {
      L = (b.size() - a.size() + 1) >> 1;
      rp(max(b.size() - L, a.size() + L - 1),
         not(a.front().first xor b.front().first xor (L & 1)), L);
    } else {
      L = (a.size() - b.size() + 1) >> 1;
      rp(max(a.size() - L, b.size() + L - 1), L,
         not(a.front().first xor b.front().first xor (L & 1)));
    }
  } else {
    if (a.size() < b.size()) {
      L = (b.size() - a.size() + 1) >> 1 | 1;
      rp(max(b.size() - L, a.size() + L - 2), 1, L);
    } else {
      L = (a.size() - b.size() + 1) >> 1 | 1;
      rp(max(a.size() - L, b.size() + L - 2), L, 1);
    }
  }
}
int main() {
  in(s, u, S), in(t, v, T);
  pick(u, v);
  if (X == -1)
    greedy();
  else {
    int F1, F2;
    F1 = F2 = 0;
    for (int i = 0; i < X; i++) F1 += u[i].second;
    for (int i = 0; i < Y; i++) F2 += v[i].second;
    add(F1, F2);
    flip(u, v, X, Y);
    greedy();
  }
  fin();
  return 0;
}
