#include <bits/stdc++.h>
using namespace std;
const int mod = (1e9) + 7;
const double eps = 1e-6;
const int siz = 2e5 + 5, siz2 = 21;
char s[siz], t[siz];
int s_sz, t_sz;
vector<pair<int, int>> moves;
vector<pair<int, int>> *sv, *tv;
bool rev;
int getval(vector<pair<int, int>> *ve, int ind) {
  return ind != -1 ? (*ve)[ind].second : 0;
}
void make_move(int si, int ti) {
  int scu = getval(sv, si), tcu = getval(tv, ti);
  moves.push_back({scu, tcu});
  vector<pair<int, int>> sc, tc;
  for (int i = ti + 1; i < tv->size(); i++) {
    int val = (*tv)[i].second - tcu;
    sc.push_back({(*tv)[i].first, val});
  }
  for (int i = si + 1; i < sv->size(); i++) {
    int val = (*sv)[i].second - scu;
    tc.push_back({(*sv)[i].first, val});
  }
  while (sv->size() > si + 1) {
    sv->pop_back();
  }
  while (tv->size() > ti + 1) {
    tv->pop_back();
  }
  int sf = 0, tf = 0;
  if (si != -1 && sc.size() > 0 && (*sv)[si].first == sc[0].first) {
    (*sv)[si].second += sc[0].second;
    sf++;
  }
  if (ti != -1 && tc.size() > 0 && (*tv)[ti].first == tc[0].first) {
    (*tv)[ti].second += tc[0].second;
    tf++;
  }
  for (int i = sf; i < sc.size(); i++) {
    int val = sc[i].second + scu;
    sv->push_back({sc[i].first, val});
  }
  for (int i = tf; i < tc.size(); i++) {
    int val = tc[i].second + tcu;
    tv->push_back({tc[i].first, val});
  }
  swap(sv, tv);
}
vector<pair<int, int>> *str_to_vctr(char *arr, int sz) {
  int co = 0;
  vector<pair<int, int>> *ret = new vector<pair<int, int>>();
  for (int i = 0; i < sz; i++) {
    if (i != 0 && arr[i] != arr[i - 1]) {
      ret->push_back({arr[i - 1], co});
    }
    co++;
  }
  ret->push_back({arr[sz - 1], co});
  return ret;
}
void fin() {
  while (sv->size() > 1) {
    make_move(sv->size() - 2, tv->size() - 2);
  }
}
void done() {
  int sz = moves.size();
  printf("%d\n", sz);
  for (auto m : moves) {
    if (rev) {
      swap(m.first, m.second);
    }
    printf("%d %d\n", m.first, m.second);
  }
  exit(0);
}
int main() {
  scanf("%s%s", s, t);
  s_sz = strlen(s);
  t_sz = strlen(t);
  sv = str_to_vctr(s, s_sz);
  tv = str_to_vctr(t, t_sz);
  int sv_sz = sv->size(), tv_sz = tv->size();
  if (sv_sz < tv_sz) {
    rev = true;
    swap(sv, tv);
    swap(sv_sz, tv_sz);
  }
  if (sv_sz == 1 && tv_sz == 1) {
    done();
  }
  if (sv_sz == tv_sz && (*sv)[0].first != (*tv)[0].first) {
    fin();
    done();
  }
  if ((*sv)[sv_sz - 1].first == (*tv)[tv_sz - 1].first) {
    if ((*sv)[0].first != (*tv)[0].first &&
        ((sv_sz % 2 == 0 && (sv_sz + tv_sz - 1) % 4 == 0) ||
         (sv_sz % 2 == 1 && (sv_sz + tv_sz + 1) % 4 == 0))) {
      if (tv_sz == 1) {
        make_move(sv_sz / 2 - 1, -1);
        make_move(sv->size() - 2, tv->size() - 1);
        make_move(0, -1);
      } else {
        int half = (sv_sz + tv_sz - 2) / 2;
        if ((*sv)[half - 1].first != (*tv)[tv_sz - 1].first) {
          half++;
        }
        make_move(half - 1, tv_sz - 2);
        if (sv->size() > tv->size()) {
          make_move(sv->size() - 2, tv->size() - 1);
        } else if (tv->size() > sv->size()) {
          make_move(sv->size() - 1, tv->size() - 2);
        }
      }
    } else {
      int half = (sv_sz + tv_sz - 1) / 2;
      if ((*sv)[half].first != (*tv)[tv_sz - 1].first) {
        half++;
      }
      make_move(half - 1, tv_sz - 1);
      if (sv->size() > tv->size()) {
        make_move(0, -1);
      } else if (tv->size() > sv->size()) {
        make_move(-1, 0);
      }
    }
  } else {
    if (((*sv)[0].first == (*tv)[0].first &&
         ((sv_sz % 2 == 1 && (sv_sz + tv_sz - 1) % 4 == 0) ||
          (sv_sz % 2 == 0 && (sv_sz + tv_sz + 1) % 4 == 0))) ||
        ((*sv)[0].first != (*tv)[0].first &&
         ((sv_sz % 2 == 1 && (sv_sz + tv_sz) % 4 == 0) ||
          (sv_sz % 2 == 0 && (sv_sz + tv_sz) % 4 != 0)))) {
      int tomove = sv_sz - (sv_sz + tv_sz) / 2;
      make_move(tomove - 1, -1);
    } else {
      if (tv_sz == 1) {
        if (sv_sz % 2 == 0) {
          make_move(sv_sz / 2 - 1, 0);
          make_move(sv->size() - 2, tv->size() - 1);
          make_move(0, -1);
        } else {
          make_move(sv_sz / 2, 0);
          make_move(sv->size() - 1, tv->size() - 2);
        }
      } else {
        int half = (sv_sz + tv_sz - 2) / 2;
        if ((*sv)[half - 1].first != (*tv)[tv_sz - 1].first) {
          half++;
        }
        make_move(half - 1, tv_sz - 2);
        if (sv->size() > tv->size()) {
          make_move(0, -1);
        } else if (tv->size() > sv->size()) {
          make_move(-1, 0);
        }
      }
    }
  }
  fin();
  done();
  return 0;
}
