#include <bits/stdc++.h>
using namespace std;
int ss[200010], st[200010];
int main() {
  string s, t;
  cin >> s >> t;
  int cnts = 0, cntt = 0;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] != s[i - 1]) {
      ss[cnts++] = i;
    }
  }
  ss[cnts] = s.length();
  for (int i = 1; i < t.length(); i++) {
    if (t[i] != t[i - 1]) {
      st[cntt++] = i;
    }
  }
  st[cntt] = t.length();
  int best = 0;
  int ct, cs;
  if (cntt > cnts) {
    best = cntt - cnts - 1 >> 1;
    best += best & 1;
    if (t[0] == s[0]) {
      if (cntt - best < cnts + best) {
        cs = ss[0];
        best--;
      } else {
        cs = 0;
      }
    } else {
      cs = ss[0];
    }
    ct = st[best];
  } else if (cntt < cnts) {
    best = cnts - cntt - 1 >> 1;
    best += best & 1;
    if (t[0] == s[0]) {
      if (cnts - best < cntt + best) {
        ct = st[0];
        best--;
      } else {
        ct = 0;
      }
    } else {
      ct = st[0];
    }
    cs = ss[best];
  }
  string temp;
  if (best > 0) {
    temp = s.substr(0, cs) + t.substr(ct, t.length());
    s = t.substr(0, ct) + s.substr(cs, s.length());
    t = temp;
    temp = to_string(cs) + " " + to_string(ct) + "\n";
    best = 1;
  }
  cnts = 0;
  cntt = 0;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] != s[i - 1]) {
      ss[cnts++] = i;
    }
  }
  for (int i = 1; i < t.length(); i++) {
    if (t[i] != t[i - 1]) {
      st[cntt++] = i;
    }
  }
  int is = 0;
  if (s[0] == t[0]) {
    if (cntt == cnts) {
      cout << cntt + 1 + best << endl << temp;
      printf("%d %d\n", 0, st[0]);
      is = st[0];
      st[cntt] = t.length();
      for (int i = 0; i < cnts; i++) {
        int a = ss[i] + is, b = st[i + 1] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
    } else if (cntt > cnts) {
      cout << cntt + best << endl << temp;
      printf("%d %d\n", 0, st[0]);
      is = st[0];
      for (int i = 0; i < cnts; i++) {
        int a = ss[i] + is, b = st[i + 1] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
      for (int i = cnts + 1; i < cntt; i++) {
        int a = s.length() + is, b = st[i] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
    } else {
      cout << cnts + best << endl << temp;
      printf("%d %d\n", ss[0], 0);
      is = -ss[0];
      for (int i = 0; i < cntt; i++) {
        int a = ss[i + 1] + is, b = st[i] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
      for (int i = cntt + 1; i < cnts; i++) {
        int a = ss[i] + is, b = t.length() - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
    }
  } else {
    cout << max(cntt, cnts) + best << endl << temp;
    if (cntt >= cnts) {
      for (int i = 0; i < cnts; i++) {
        int a = ss[i] + is, b = st[i] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
      for (int i = cnts; i < cntt; i++) {
        int a = s.length() + is, b = st[i] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
    } else {
      for (int i = 0; i < cntt; i++) {
        int a = ss[i] + is, b = st[i] - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
      for (int i = cntt; i < cnts; i++) {
        int a = ss[i] + is, b = t.length() - is;
        printf("%d %d\n", a, b);
        is += b - a;
      }
    }
  }
  return 0;
}
