#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long long n = (a).size();
  map<char, char> m, m2;
  for (int i = 0; i < int(n); i++) {
    m[a[i]] = b[i];
    m[b[i]] = a[i];
  }
  for (int i = 0; i < int(n); i++) {
    if (m[a[i]] != b[i] || m[b[i]] != a[i]) {
      cout << -1;
      exit(0);
    }
    if (m2[a[i]] != b[i] && m2[b[i]] != a[i] && a[i] != b[i]) m2[a[i]] = b[i];
  }
  vector<pair<char, char>> v;
  for (auto c : m2) {
    if (c.second) v.push_back(make_pair(c.first, c.second));
  }
  cout << (v).size() << endl;
  for (auto c : v) cout << c.first << ' ' << c.second << endl;
  return 0;
}
