#include <bits/stdc++.h>
using namespace std;
long long n;
string s, t;
map<char, char> v;
vector<pair<char, char> > g;
int main() {
  cin >> s >> t;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == t[i]) {
      if (v[s[i]] == 0 && v[t[i]] == 0)
        v[s[i]] = t[i], v[t[i]] = s[i];
      else if (v[s[i]] != t[i] || v[t[i]] != s[i]) {
        cout << -1;
        return 0;
      }
    } else {
      if (v[s[i]] == 0 && v[t[i]] == 0) {
        v[t[i]] = s[i], v[s[i]] = t[i];
        g.push_back(make_pair(min(s[i], t[i]), max(s[i], t[i])));
      } else if (v[t[i]] != s[i] || v[s[i]] != t[i]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << g.size() << endl;
  for (vector<pair<char, char> >::iterator it = g.begin(); it != g.end(); it++)
    cout << it->first << " " << it->second << endl;
}
