#include <bits/stdc++.h>
const long long N = 1e5 + 100;
using namespace std;
map<char, char> p;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int len = s1.length(), sum = 0;
  for (int i = 0; i < len; i++) {
    if (p[s1[i]] == 0 && p[s2[i]] == 0) {
      p[s1[i]] = s2[i];
      p[s2[i]] = s1[i];
      if (s2[i] != s1[i]) sum++;
    } else {
      if (p[s1[i]] == s2[i] && p[s2[i]] == s1[i]) {
        continue;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << sum << endl;
  map<char, char>::iterator it;
  map<char, int> f;
  it = p.begin();
  while (it != p.end()) {
    if (it->first != it->second && f[it->first] == 0 && f[it->second] == 0) {
      cout << it->first << " " << it->second << endl;
      f[it->first] = 1;
      f[it->second] = 1;
    } else {
      f[it->first] = 1;
      f[it->second] = 1;
    }
    it++;
  }
}
