#include <bits/stdc++.h>
using namespace std;
map<char, char> m;
char s[1005], t[1005];
int vis[30];
bool p[30];
int main() {
  bool flag = 0;
  map<char, char>::iterator it1, it2;
  scanf(" %s %s", s, t);
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == t[i]) {
      char ch = s[i];
      if (vis[ch - 'a'] != 2) {
        vis[ch - 'a'] = 1;
      } else {
        flag = 1;
        break;
      }
    } else {
      if (vis[s[i] - 'a'] == 0 && vis[t[i] - 'a'] == 0) {
        m.insert(make_pair(s[i], t[i]));
        vis[s[i] - 'a'] = 2;
        vis[t[i] - 'a'] = 2;
      } else if (vis[s[i] - 'a'] == 2 && vis[t[i] - 'a'] == 2) {
        it1 = m.find(s[i]);
        it2 = m.find(t[i]);
        if (it1 != m.end() && it2 != m.end()) {
          flag = 1;
          break;
        }
        if (it1 != m.end()) {
          if (it1->second != t[i]) {
            flag = 1;
            break;
          }
        }
        if (it2 != m.end()) {
          if (it2->second != s[i]) {
            flag = 1;
            break;
          }
        }
      } else {
        flag = 1;
        break;
      }
    }
  }
  if (flag) {
    printf("%d\n", -1);
  } else {
    printf("%d\n", m.size());
    for (int i = 0; i < strlen(s); i++) {
      char ch = s[i];
      if (vis[ch - 'a'] == 1) continue;
      it1 = m.find(ch);
      if (it1 == m.end()) continue;
      if (p[it1->first - 'a'] == 0) printf("%c  %c\n", it1->first, it1->second);
      p[it1->first - 'a'] = 1;
    }
  }
  return 0;
}
