#include <bits/stdc++.h>
using namespace std;
map<char, char> a, a1;
map<char, int> b, b2;
pair<char, char> b1[1000 + 100];
int n, k;
string s, s1;
int main() {
  cin >> s >> s1;
  n = s.length();
  for (int i = 0; i <= n - 1; i++) {
    if (b[s[i]] < 1 && b[s1[i]] < 1) {
      a[s[i]] = s1[i];
      a1[s1[i]] = s[i];
      b[s[i]]++;
      b[s1[i]]++;
    } else {
      if ((a[s[i]] != s1[i] || a1[s1[i]] != s[i]) && (a[s1[i]] != s[i])) {
        printf("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i <= n - 1; i++) {
    if (s[i] != s1[i] && b[s[i]] != -1 && b[s1[i]] != -1) {
      b[s[i]] = -1;
      b[s1[i]] = -1;
      k++;
      b1[k].first = s[i];
      b1[k].second = s1[i];
    }
  }
  if (k == 0) {
    cout << "0" << endl;
    return 0;
  }
  printf("%d\n", k);
  for (int i = 1; i <= k; i++)
    cout << b1[i].first << ' ' << b1[i].second << endl;
  return 0;
}
