#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > sol;
vector<pair<char, int> > v1, v2, a, b;
int b1 = 0;
vector<pair<char, int> > f(string s) {
  vector<pair<char, int> > ret;
  for (int i = 0; i < s.size(); i++) {
    int i2 = i;
    while (i2 + 1 < s.size() && s[i2] == s[i2 + 1]) i2 += 1;
    ret.push_back(make_pair(s[i], i2 - i + 1));
    i = i2;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
void merge(int b2, vector<pair<char, int> > y) {
  if (b2) {
    for (int i = y.size() - 1; i >= 0; i--) {
      if (!v2.empty() && v2.back().first == y[i].first)
        v2.back().second += y[i].second;
      else
        v2.push_back(y[i]);
    }
  } else {
    for (int i = y.size() - 1; i >= 0; i--) {
      if (!v1.empty() && v1.back().first == y[i].first)
        v1.back().second += y[i].second;
      else
        v1.push_back(y[i]);
    }
  }
}
int l(vector<pair<char, int> > v) {
  int ret = 0;
  for (int i = 0; i < v.size(); i++) ret += v[i].second;
  return ret;
}
void swap_pref(int p1, int p2) {
  if (p1 > v1.size() or p2 > v2.size()) {
  }
  a.clear();
  b.clear();
  int l1 = 0, l2 = 0;
  for (int i = 0; i < p1; i++) {
    l1 += v1.back().second;
    a.push_back(v1.back());
    v1.pop_back();
  }
  for (int i = 0; i < p2; i++) {
    l2 += v2.back().second;
    b.push_back(v2.back());
    v2.pop_back();
  }
  if (b1) swap(l1, l2);
  sol.push_back(make_pair(l1, l2));
  merge(0, b);
  merge(1, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;
  v1 = f(s);
  v2 = f(t);
  while (v1.size() != 1 or v2.size() != 1) {
    int l1 = v1.size(), l2 = v2.size();
    if (l1 < l2) {
      swap(l1, l2);
      swap(v1, v2);
      b1 = !b1;
    }
    char c1 = v1.back().first, c2 = v2.back().first;
    if (c1 != c2) {
      if (l2 <= 2) {
        if (l1 <= 3)
          swap_pref(1, 1);
        else
          swap_pref(3, 1);
      } else
        swap_pref(1, 1);
    } else {
      if (l2 == 1) {
        if (l1 <= 3)
          swap_pref(1, 0);
        else
          swap_pref(3, 0);
      } else if (l2 == 2) {
        if (l1 == 2)
          swap_pref(1, 0);
        else
          swap_pref(2, 1);
      } else
        swap_pref(3, 2);
    }
  }
  cout << sol.size() << "\n";
  for (int i = 0; i < sol.size(); i++) {
    cout << sol[i].first << " " << sol[i].second << "\n";
  }
  return 0;
}
