#include <bits/stdc++.h>
using namespace std;
map<char, bool> m;
vector<pair<char, char> > v;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int n = s1.size();
  for (int i = 0; i < n; i++) {
    if (s1[i] != s2[i] && m[s1[i]] == 0 && m[s2[i]] == 0) {
      v.push_back({s1[i], s2[i]});
      m[s1[i]] = 1;
      m[s2[i]] = 1;
    }
  }
  for (int i = 0; i < v.size(); i++) {
    char l = v[i].first, r = v[i].second;
    for (int k = 0; k < s2.size(); k++) {
      if (s2[k] == r)
        s2[k] = l;
      else if (s2[k] == l)
        s2[k] = r;
    }
  }
  if (s1 == s2) {
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i].first << " " << v[i].second << endl;
    }
  } else
    cout << "-1" << endl;
  return 0;
}
