#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, cnt = 0;
  string p, q;
  char t, a;
  map<char, char> c;
  cin >> p >> q;
  for (i = 0; i < p.size(); i++) {
    if ((c[q[i]] != 0 || c[p[i]] != 0) &&
        (c[q[i]] != p[i] || c[p[i]] != q[i])) {
      cout << -1;
      return 0;
    }
    if (c[q[i]] == 0 && p[i] != q[i]) cnt++;
    c[q[i]] = p[i];
    c[p[i]] = q[i];
  }
  cout << cnt << endl;
  for (t = 'a'; t <= 'z'; t++) {
    if (c[t] != 0 && c[t] != t) {
      cout << t << " " << c[t] << endl;
      c[c[t]] = 0;
    }
  }
  return 0;
}
