#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    vector<int> blocks;
    vector<int> blockt;
    int currsiz = 1;
    for (int i = 1; i < n; i++) {
      if (s.at(i) != s.at(i - 1)) {
        blocks.push_back(currsiz);
        currsiz = 1;
      } else {
        currsiz++;
      }
    }
    blocks.push_back(currsiz);
    currsiz = 1;
    for (int i = 1; i < m; i++) {
      if (t.at(i) != t.at(i - 1)) {
        blockt.push_back(currsiz);
        currsiz = 1;
      } else {
        currsiz++;
      }
    }
    blockt.push_back(currsiz);
    vector<pair<int, int> > moves;
    reverse(blocks.begin(), blocks.end());
    reverse(blockt.begin(), blockt.end());
    bool eq = (s.at(0) == t.at(0));
    while (blocks.size() > 1 || blockt.size() > 1) {
      if (eq) {
        if (blocks.size() == 1) {
          swap(blockt, blocks);
          if (blocks.size() == 2) {
            moves.push_back({0, blocks[1]});
            break;
          }
          int diff = blocks.size() / 2;
          if (diff % 2 == 0) {
            diff--;
            if (blocks.size() % 2 == 1) {
              diff += 2;
            }
          }
          vector<int> topushb;
          int moved = blocks[blocks.size() - diff];
          blockt[0] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({0, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = false;
          swap(blockt, blocks);
        } else if (blockt.size() == 1) {
          if (blocks.size() == 2) {
            moves.push_back({blocks[1], 0});
            break;
          }
          int diff = blocks.size() / 2;
          if (diff % 2 == 0) {
            diff--;
            if (blocks.size() % 2 == 1) {
              diff += 2;
            }
          }
          vector<int> topushb;
          int moved = blocks[blocks.size() - diff];
          blockt[0] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, 0});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = false;
        }
        if (eq) {
          if (blocks.size() > blockt.size() + 2) {
            int diff = (blocks.size() - blockt.size() + 1) / 2;
            if (diff % 2 == 1) {
              diff++;
            }
            vector<int> topushb;
            int moved = blocks[blocks.size() - diff];
            int removed = blockt[blockt.size() - 1];
            blockt.pop_back();
            blockt[blockt.size() - 1] += blocks[blocks.size() - diff];
            for (int i = diff - 1; i >= 1; i--) {
              moved += blocks[blocks.size() - i];
              blockt.push_back(blocks[blocks.size() - i]);
            }
            moves.push_back({moved, removed});
            for (int i = 1; i <= diff; i++) {
              blocks.pop_back();
            }
            blocks[blocks.size() - 1] += removed;
          } else if (blockt.size() > blocks.size() + 2) {
            swap(blocks, blockt);
            int diff = (blocks.size() - blockt.size() + 1) / 2;
            if (diff % 2 == 1) {
              diff++;
            }
            vector<int> topushb;
            int moved = blocks[blocks.size() - diff];
            int removed = blockt[blockt.size() - 1];
            blockt.pop_back();
            blockt[blockt.size() - 1] += blocks[blocks.size() - diff];
            for (int i = diff - 1; i >= 1; i--) {
              moved += blocks[blocks.size() - i];
              blockt.push_back(blocks[blocks.size() - i]);
            }
            moves.push_back({removed, moved});
            for (int i = 1; i <= diff; i++) {
              blocks.pop_back();
            }
            blocks[blocks.size() - 1] += removed;
            swap(blocks, blockt);
          }
          if (blocks.size() > blockt.size()) {
            moves.push_back({blocks[blocks.size() - 1], 0});
            blockt[blockt.size() - 1] += (blocks[blocks.size() - 1]);
            blocks.pop_back();
          } else {
            moves.push_back({0, blockt[blockt.size() - 1]});
            blocks[blocks.size() - 1] += (blockt[blockt.size() - 1]);
            blockt.pop_back();
          }
          eq = false;
        }
      } else {
        if (blockt.size() == 1) {
          if (blocks.size() == 2) {
            moves.push_back({blocks[1], blockt[0]});
            break;
          }
          int diff = int(blocks.size()) - int(blockt.size());
          diff /= 2;
          if (diff % 2 == 0) {
            diff++;
          }
          vector<int> topushb;
          int removed = blockt[0];
          blockt.pop_back();
          int moved = 0;
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, removed});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = false;
        } else if (blocks.size() == 1) {
          swap(blocks, blockt);
          if (blocks.size() == 2) {
            moves.push_back({
                blockt[0],
                blocks[1],
            });
            break;
          }
          int diff = int(blocks.size()) - int(blockt.size());
          diff /= 2;
          if (diff % 2 == 0) {
            diff++;
          }
          vector<int> topushb;
          int removed = blockt[0];
          blockt.pop_back();
          int moved = 0;
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({removed, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = false;
          swap(blocks, blockt);
        } else if (blocks.size() > blockt.size() + 2) {
          int diff = (blocks.size() - blockt.size() + 1) / 2;
          if (diff % 2 == 0) {
            diff++;
          }
          vector<int> topushb;
          int moved = blocks[blocks.size() - diff];
          int removed = blockt[blockt.size() - 1];
          blockt.pop_back();
          blockt[blockt.size() - 1] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, removed});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = false;
        } else if (blockt.size() > blocks.size() + 2) {
          swap(blocks, blockt);
          int diff = (blocks.size() - blockt.size() + 1) / 2;
          if (diff % 2 == 0) {
            diff++;
          }
          vector<int> topushb;
          int moved = blocks[blocks.size() - diff];
          int removed = blockt[blockt.size() - 1];
          blockt.pop_back();
          blockt[blockt.size() - 1] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({removed, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = false;
          swap(blocks, blockt);
        }
      }
      if (eq) {
        if (blocks.size() == 1) {
          swap(blockt, blocks);
          if (blocks.size() == 2) {
            moves.push_back({0, blocks[1]});
            break;
          }
          int diff = blocks.size() / 2;
          if (diff % 2 == 1) {
            diff++;
          }
          vector<int> topushb;
          int moved = 0;
          int removed = blockt[0];
          blockt.pop_back();
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({removed, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = true;
          swap(blockt, blocks);
        } else if (blockt.size() == 1) {
          if (blocks.size() == 2) {
            moves.push_back({blocks[1], 0});
            break;
          }
          int diff = blocks.size() / 2;
          if (diff % 2 == 1) {
            diff++;
          }
          vector<int> topushb;
          int moved = 0;
          int removed = blockt[0];
          blockt.pop_back();
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, removed});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          blocks[blocks.size() - 1] += removed;
          eq = true;
        }
        if (blocks.size() > blockt.size()) {
          moves.push_back({blocks[blocks.size() - 1], 0});
          blockt[blockt.size() - 1] += (blocks[blocks.size() - 1]);
          blocks.pop_back();
        } else {
          moves.push_back({0, blockt[blockt.size() - 1]});
          blocks[blocks.size() - 1] += (blockt[blockt.size() - 1]);
          blockt.pop_back();
        }
      }
      while (blocks.size() > 1 && blockt.size() > 1) {
        int siz1 = blocks[blocks.size() - 1];
        int siz2 = blockt[blockt.size() - 1];
        moves.push_back({siz1, siz2});
        blocks.pop_back();
        blocks[blocks.size() - 1] += siz2;
        blockt.pop_back();
        blockt[blockt.size() - 1] += siz1;
      }
      if (blocks.size() > 1) {
        if (blocks.size() == 2) {
          moves.push_back({blocks[1], blockt[0]});
          break;
        }
        int diff = int(blocks.size()) - int(blockt.size());
        diff /= 2;
        if (diff % 2) {
          diff++;
        }
        if (diff % 2) {
          vector<int> topushb;
          int moved = 0;
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, 0});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = false;
        } else {
          vector<int> topushb;
          int moved = 0;
          moved += blocks[blocks.size() - diff];
          blockt[0] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({moved, 0});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = true;
        }
      } else if (blockt.size() > 1) {
        swap(blocks, blockt);
        if (blocks.size() == 2) {
          moves.push_back({
              blockt[0],
              blocks[1],
          });
          break;
        }
        int diff = int(blocks.size()) - int(blockt.size());
        diff /= 2;
        if (diff % 2) {
          diff++;
        }
        if (diff % 2) {
          vector<int> topushb;
          int moved = 0;
          for (int i = diff; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({0, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = false;
        } else {
          vector<int> topushb;
          int moved = 0;
          moved += blocks[blocks.size() - diff];
          blockt[0] += blocks[blocks.size() - diff];
          for (int i = diff - 1; i >= 1; i--) {
            moved += blocks[blocks.size() - i];
            blockt.push_back(blocks[blocks.size() - i]);
          }
          moves.push_back({0, moved});
          for (int i = 1; i <= diff; i++) {
            blocks.pop_back();
          }
          eq = true;
        }
        swap(blocks, blockt);
      }
    }
    cout << moves.size() << endl;
    for (auto el : moves) {
      cout << el.first << " " << el.second << "\n";
    }
  }
  return 0;
}
