#include <bits/stdc++.h>
using namespace std;
int c[500];
int main() {
  string s, t;
  int n, i, j, k;
  cin >> s >> t;
  bool ok = 1;
  vector<pair<char, char> > ans;
  n = s.length();
  vector<char> v(500, '0');
  for (i = 0; i < n; i++) {
    if (s[i] == t[i]) {
      if (c[s[i]] == -2) ok = 0;
      c[s[i]] = -1;
      continue;
    } else if (c[s[i]] == -1 || c[t[i]] == -1) {
      ok = 0;
    } else if (!c[s[i]] && !c[t[i]]) {
      ans.push_back({s[i], t[i]});
      c[s[i]] = -2;
      v[s[i]] = t[i];
      c[t[i]] = -2;
      v[t[i]] = s[i];
    } else if (c[s[i]] == -2 && c[t[i]] == -2) {
      if (v[s[i]] != t[i] || v[t[i]] != s[i]) ok = 0;
    } else
      ok = 0;
  }
  if (!ok) return cout << -1, 0;
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second << endl;
  }
}
