#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
char str1[maxn], str2[maxn];
int main() {
  scanf("%s%s", str1, str2);
  map<char, char> ID;
  int len = strlen(str1);
  vector<char> pool;
  for (int i = 0; i < len; i++) {
    if (ID.count(str1[i])) {
      if (ID[str1[i]] != str2[i]) {
        puts("-1");
        return 0;
      }
    } else if (ID.count(str2[i])) {
      if (ID[str2[i]] != str1[i]) {
        puts("-1");
        return 0;
      }
    } else {
      ID[str1[i]] = str2[i];
      ID[str2[i]] = str1[i];
      if (str1[i] != str2[i]) pool.push_back(str1[i]);
    }
  }
  printf("%d\n", pool.size());
  for (int i = 0; i < pool.size(); i++) {
    printf("%c %c\n", pool[i], ID[pool[i]]);
  }
  return 0;
}
