#include <bits/stdc++.h>
using namespace std;
int main() {
  int w = 0;
  string s1, s2;
  map<char, char> m;
  cin >> s1 >> s2;
  for (int i = 0; i < s1.size(); i++) {
    if (m[s1[i]] != s2[i] && m[s1[i]] != 0) {
      cout << -1 << endl;
      return 0;
    }
    if (m[s2[i]] != s1[i] && m[s2[i]] != 0) {
      cout << -1 << endl;
      return 0;
    }
    m[s1[i]] = s2[i];
    m[s2[i]] = s1[i];
  }
  for (char i = 'a'; i <= 'z'; i++) {
    if (m[i] != 0 && m[i] != i) {
      w++;
      m[m[i]] = 0;
    }
  }
  cout << w << endl;
  for (char i = 'a'; i <= 'z'; i++) {
    if (m[i] != 0 && m[i] != i) {
      cout << i << ' ' << m[i] << endl;
    }
  }
  return 0;
}
