#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e9;
inline long long int in() {
  long long int _x = 0, _t = 1;
  char _ch = getchar();
  while ((_ch < '0' || _ch > '9') && _ch != '-') _ch = getchar();
  if (_ch == '-') _ch = getchar(), _t = -1;
  while (_ch >= '0' && _ch <= '9') _x *= 10, _x += (_ch - '0'), _ch = getchar();
  return _x * _t;
}
int main() {
  string o, t;
  cin >> o >> t;
  map<char, set<char> > m;
  set<pair<char, char> > s;
  int i = 0;
  bool flag = 1;
  while (o[i]) {
    char a, b;
    a = o[i], b = t[i];
    m[a].insert(b);
    m[b].insert(a);
    if (a != b) {
      if (a > b) swap(a, b);
      s.insert(make_pair(a, b));
    }
    if (m[a].size() > 1 || m[b].size() > 1) flag = 0;
    i++;
  }
  if (flag == 0)
    cout << -1 << endl;
  else {
    cout << s.size() << endl;
    for (auto p : s) cout << p.first << " " << p.second << endl;
  }
  return 0;
}
