#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  map<char, set<char>> g;
  map<char, int> used;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] != s2[i]) {
      g[s1[i]].insert(s2[i]);
      g[s2[i]].insert(s1[i]);
    } else {
      used[s1[i]] = 1;
    }
  }
  for (auto& i : g) {
    if (i.second.size() > 1 || (i.second.size() && used[i.first])) {
      cout << -1;
      return 0;
    }
  }
  vector<pair<char, char>> ans;
  for (auto& i : g) {
    if (i.second.size()) {
      if (i.first < *i.second.begin()) {
        ans.push_back({i.first, *i.second.begin()});
      }
    }
  }
  cout << ans.size() << endl;
  for (auto& i : ans) cout << i.first << ' ' << i.second << endl;
  return 0;
}
