#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
char s[200105], t[200105];
int S, T;
vector<pair<int, int> > ans[2];
vector<int> a, b;
void wk(int w, int x, int y) {
  if (a.empty()) a.push_back(0);
  if (b.empty()) b.push_back(0);
  vector<int> c, d;
  for (int(i) = 0; (i) < (int)(x); (i)++) {
    c.push_back(a.back());
    a.pop_back();
  }
  for (int(i) = 0; (i) < (int)(y); (i)++) {
    d.push_back(b.back());
    b.pop_back();
  }
  int la = a.back(), lb = b.back();
  ans[w].push_back({la, lb});
  a.pop_back();
  b.pop_back();
  swap(a, b);
  while (!c.empty()) {
    a.push_back(c.back() - la + lb);
    c.pop_back();
  }
  while (!d.empty()) {
    b.push_back(d.back() - lb + la);
    d.pop_back();
  }
}
void cal(int w) {
  for (int(i) = 0; (i) < (int)(S); (i)++)
    if (s[i] != s[i + 1]) a.push_back(i + 1);
  for (int(i) = 0; (i) < (int)(T); (i)++)
    if (t[i] != t[i + 1]) b.push_back(i + 1);
  while (1) {
    if ((a.size() > 1 && b.size() > 1))
      wk(w, 0, 0);
    else if ((a.size() || b.size()) && a.size() < 3 && b.size() < 3)
      wk(w, 0, 0);
    else if (a.size() > 2)
      wk(w, 2, 0);
    else if (b.size() > 2)
      wk(w, 0, 2);
    else
      return;
  }
}
void fmain(int ID) {
  scanf("%s%s", s, t);
  S = strlen(s);
  T = strlen(t);
  s[S] = 'a';
  t[T] = 'b';
  cal(0);
  swap(s[S], t[T]);
  cal(1);
  if (ans[0].size() > ans[1].size()) swap(ans[0], ans[1]);
  printf("%d\n", ans[0].size());
  for (auto p : ans[0]) {
    printf("%d %d\n", p.first, p.second);
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
