#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1;
  cin >> s >> s1;
  map<char, char> B;
  set<char> A;
  for (int i = 0; i < s.size(); ++i) {
    if (A.count(s[i])) {
      if (B[s[i]] != s1[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (A.count(s1[i])) {
      if (B[s1[i]] != s[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
    B[s[i]] = s1[i];
    B[s1[i]] = s[i];
    A.insert(s[i]);
    A.insert(s1[i]);
  }
  vector<pair<char, char> > Res;
  for (auto a : B) {
    if (a.first != a.second) {
      Res.push_back(a);
      B[a.first] = a.first;
      B[a.second] = a.second;
    }
  }
  cout << Res.size() << endl;
  for (int i = 0; i < Res.size(); ++i) {
    cout << Res[i].first << " " << Res[i].second << endl;
  }
  return 0;
}
