#include <bits/stdc++.h>
using namespace std;
map<char, pair<int, char>> m;
string s, t;
bool used[256];
int q1[256];
int q2[256];
int main() {
  cin >> s >> t;
  for (char i = 'a'; i <= 'z'; i++) {
    m[i].first = 0;
  }
  for (int i = 0; i < s.length(); i++) {
    q1[s[i]]++;
    q2[t[i]]++;
    if (s[i] != t[i]) {
      m[s[i]].first++;
      if (m[s[i]].second == t[i]) m[s[i]].first = 1;
      if (q1[s[i]] >= 2 && m[s[i]].second != t[i]) {
        cout << -1;
        return 0;
      }
      m[s[i]].second = t[i];
      m[t[i]].second = s[i];
      if (m[s[i]].first >= 2) {
        cout << -1;
        return 0;
      }
    } else
      m[s[i]].second = t[i];
  }
  for (char i = 'a'; i <= 'z'; i++) {
    if (m[i].first == 1 && q1[i] != q2[m[i].second]) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < s.length(); i++) {
    if (m[s[i]].first == 1) {
      if (s[i] != m[m[s[i]].second].second) {
        cout << -1;
        return 0;
      }
    }
  }
  int ans = 0;
  for (char i = 'a'; i <= 'z'; i++) {
    if (m[i].first == 1 && !used[i]) {
      used[i] = 1;
      used[m[i].second] = 1;
      ans++;
    }
  }
  for (char i = 'a'; i <= 'z'; i++) used[i] = 0;
  cout << ans << endl;
  for (char i = 'a'; i <= 'z'; i++) {
    if (m[i].first == 1) {
      if (!used[i] && !used[m[i].second]) {
        used[i] = 1;
        used[m[i].second] = 1;
        cout << i << ' ' << m[i].second << endl;
      }
    }
  }
  return 0;
}
