#include <bits/stdc++.h>
using namespace std;
string s, t;
map<char, int> k1;
map<char, int> k2;
map<char, bool> was;
map<char, int> tt;
vector<pair<char, char> > ans;
int main() {
  cin >> s >> t;
  if (s.compare(t) == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    k1[s[i]]++;
    k2[t[i]]++;
  }
  for (int i = 0; i < s.size(); i++)
    if (k1[s[i]] != k2[t[i]]) {
      cout << -1;
      return 0;
    }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == t[i]) was[s[i]] = true;
    if (s[i] != t[i]) {
      if (was[s[i]] == false && was[t[i]] == false) {
        ans.push_back(make_pair(s[i], t[i]));
        was[s[i]] = true;
        was[t[i]] = true;
        tt[s[i]] = ans.size();
        tt[t[i]] = ans.size();
      }
      if (was[s[i]] == false && was[t[i]] == true ||
          was[s[i]] == true && was[t[i]] == false) {
        cout << -1;
        return 0;
      }
      if (was[s[i]] != false && was[t[i]] != false)
        if (tt[s[i]] != tt[t[i]]) {
          cout << -1;
          return 0;
        }
    }
  }
  if (ans.size() == 0) {
    cout << -1;
    return 0;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
