#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  map<char, char> m, m1;
  bool ok = true;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] == b[i] && m.count(a[i]) == 0 && m1.count(a[i]) == 0) {
      m[a[i]] = b[i];
      m1[b[i]] = a[i];
    } else if (m.count(a[i]) > 0) {
      if (m[a[i]] != b[i]) {
        ok = false;
        break;
      }
    } else if (m1.count(a[i]) > 0) {
      if (m1[a[i]] != b[i]) {
        ok = false;
        break;
      }
    } else if (m.count(b[i]) > 0) {
      if (m[b[i]] != a[i]) {
        ok = false;
        break;
      }
    } else if (m1.count(b[i]) > 0) {
      if (m1[b[i]] != a[i]) {
        ok = false;
        break;
      }
    } else {
      m[a[i]] = b[i];
      m1[b[i]] = a[i];
    }
  }
  if (!ok) {
    cout << -1;
    return 0;
  }
  vector<pair<char, char>> ans;
  for (auto i : m) {
    if (i.first == i.second) continue;
    ans.push_back(i);
  }
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i.first << " " << i.second << "\n";
  return 0;
}
