#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s1, s2;
  cin >> s1 >> s2;
  int n = s1.length();
  map<char, char> m;
  int arr[26] = {};
  int flag = 1;
  for (int i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      if (arr[s1[i] - 'a'] == arr[s2[i] - 'a']) {
        if (arr[s1[i] - 'a'] == 0) {
          m.insert({s1[i], s2[i]});
          arr[s1[i] - 'a'] = arr[s2[i] - 'a'] = 1;
        } else {
          if (m.find(s1[i])->second == s2[i] ||
              m.find(s2[i])->second == s1[i]) {
            continue;
          } else {
            flag = 0;
            break;
          }
        }
      } else {
        flag = 0;
        break;
      }
    } else {
      if (arr[s1[i] - 'a'] == 0 || arr[s1[i] - 'a'] == -1) {
        arr[s1[i] - 'a'] = -1;
        continue;
      } else {
        flag = 0;
        break;
      }
    }
  }
  if (flag == 0) {
    cout << -1;
    return 0;
  }
  cout << m.size() << endl;
  for (auto a : m) {
    cout << a.first << " " << a.second << endl;
  }
  return 0;
}
