#include <bits/stdc++.h>
using namespace std;
long long int vis[26];
int main() {
  long long int i, j, k, m, t;
  string p, q;
  cin >> p >> q;
  map<char, char> cn;
  set<pair<char, char> > st;
  for (i = 0; i < p.size(); i++) {
    long long int c1 = p[i] - 97, c2 = q[i] - 97;
    if ((!vis[c1] && vis[c2]) || (vis[c1] && !vis[c2])) {
      cout << "-1";
      return 0;
    }
    if (!vis[c1]) {
      vis[c1] = 1, vis[c2] = 1;
      cn[p[i]] = q[i];
      cn[q[i]] = p[i];
    } else if (vis[c1]) {
      if (q[i] != cn[p[i]]) {
        cout << "-1";
        return 0;
      }
    }
  }
  for (i = 0; i < p.size(); i++) {
    char p1 = p[i];
    char p2 = q[i];
    if (p1 > p2) swap(p1, p2);
    if (p1 != p2) st.insert({p1, p2});
  }
  cout << st.size() << "\n";
  for (set<pair<char, char> >::iterator it = st.begin(); it != st.end(); it++) {
    pair<char, char> now = *it;
    cout << now.first << " " << now.second << "\n";
  }
}
