#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, mod = 1e9 + 7;
string a, b;
map<char, char> h;
vector<pair<char, char> > res;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base ::sync_with_stdio();
  cin >> a >> b;
  for (int i = 0; i < ((int)a.size()); i++) {
    if (h[a[i]] == 0 && h[b[i]] == 0) {
      if (a[i] != b[i]) res.push_back({a[i], b[i]});
      h[a[i]] = b[i];
      h[b[i]] = a[i];
    } else {
      if (h[a[i]] != b[i]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ((int)res.size()) << "\n";
  for (pair<char, char> u : res) cout << u.first << " " << u.second << "\n";
  return 0;
}
