#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  map<char, char> v, u;
  long long int r = 0;
  cin >> a;
  cin >> b;
  for (int i = 0; i < a.size(); i++) {
    if (v.find(a[i]) == v.end() && v.find(b[i]) == v.end()) {
      v[a[i]] = b[i];
      v[b[i]] = a[i];
      if (a[i] != b[i]) {
        u[a[i]] = b[i];
        r++;
      }
    } else if (v[a[i]] != b[i] || v[b[i]] != a[i]) {
      cout << -1;
      return 0;
    }
  }
  cout << r << endl;
  for (auto i = u.begin(); i != u.end(); i++) {
    cout << i->first << " " << i->second << endl;
  }
  return 0;
}
