#include <bits/stdc++.h>
using namespace std;
const int pi = 3.14159265;
const int INF = 1 << 30;
const int maxn = 1e5;
map<char, set<char> > mp, mp2, mp3, mp4;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < a.size(); ++i) {
    mp[a[i]].insert(b[i]);
    mp2[b[i]].insert(a[i]);
    mp3[min(a[i], b[i])].insert(max(a[i], b[i]));
    mp4[max(a[i], b[i])].insert(min(a[i], b[i]));
    if (mp[a[i]].size() > 1) {
      cout << -1 << endl;
      return 0;
    }
    if (mp2[b[i]].size() > 1) {
      cout << -1 << endl;
      return 0;
    }
    if (mp3[min(a[i], b[i])].size() > 1) {
      cout << -1 << endl;
      return 0;
    }
    if (mp4[max(a[i], b[i])].size() > 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  map<char, char> ans;
  map<char, set<char> >::iterator it;
  for (it = mp.begin(); it != mp.end(); ++it) {
    set<char>::iterator ot;
    ot = (it->second).begin();
    if ((it->first) != (*ot)) {
      ans[min((it->first), (*ot))] = max((it->first), (*ot));
    }
  }
  cout << ans.size() << endl;
  map<char, char>::iterator ot;
  for (ot = ans.begin(); ot != ans.end(); ++ot) {
    cout << (ot->first) << " " << (ot->second) << endl;
  }
}
