#include <bits/stdc++.h>
using namespace std;
map<char, char> a;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int dl = s1.size();
  int k = 0;
  for (int i = 0; i < dl; i++) {
    char p1 = s1[i];
    char p2 = s2[i];
    map<char, char>::iterator it = a.find(p1);
    if (it == a.end()) {
      a[p1] = p2;
      if (p1 == p2) k++;
    } else if (it->second != p2) {
      cout << -1;
      exit(0);
    }
    it = a.find(p2);
    if (it == a.end()) {
      a[p2] = p1;
      if (p1 == p2) k++;
    } else if (it->second != p1) {
      cout << -1;
      exit(0);
    }
  }
  cout << (a.size() - k) / 2 << '\n';
  for (map<char, char>::iterator it = a.begin(); it != a.end(); it++) {
    if (it->first >= it->second) continue;
    cout << it->first << " " << it->second << '\n';
  }
  return 0;
}
