#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
char a[1005];
char b[1005];
set<char> s;
map<char, char> mp;
int main() {
  scanf("%s", a);
  scanf("%s", b);
  int len = strlen(a);
  int f = 0, ff = 0;
  int ans = 0;
  for (int i = 0; i < len; i++) {
    char c1 = a[i];
    char c2 = b[i];
    if (c1 > c2) {
      char t = c2;
      c2 = c1;
      c1 = t;
    }
    if (s.count(c1) || s.count(c2)) {
      if (mp.count(c1)) {
        if (mp[c1] == c2)
          continue;
        else {
          f = 1;
          break;
        }
      } else {
        f = 1;
        break;
      }
    } else {
      s.insert(c1);
      s.insert(c2);
      mp[c1] = c2;
      if (c1 != c2) ans++;
    }
  }
  if (f == 0) {
    printf("%d\n", ans);
    for (map<char, char>::iterator it = mp.begin(); it != mp.end(); it++) {
      if (it->first != it->second) printf("%c %c\n", it->first, it->second);
    }
  } else
    printf("-1\n");
  return 0;
}
