#include <bits/stdc++.h>
using namespace std;
map<char, char> mp;
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((mp[s[i]] != 0 || mp[t[i]] != 0) &&
        (mp[s[i]] != t[i] || mp[t[i]] != s[i])) {
      cout << -1;
      return 0;
    }
    if (s[i] != t[i] && mp[t[i]] == 0) {
      ans++;
    }
    mp[s[i]] = t[i];
    mp[t[i]] = s[i];
  }
  cout << ans << endl;
  for (char i = 'a'; i <= 'z'; i++) {
    if (mp[i] != 0 && mp[i] != i) {
      cout << i << " " << mp[i] << endl;
      mp[mp[i]] = 0;
    }
  }
}
