#include <bits/stdc++.h>
using namespace std;
void die(int a) {
  cout << a << endl;
  exit(0);
}
int main() {
  string ri, wr;
  cin >> ri >> wr;
  char arr[30];
  for (int i = 0; i < 30; i++) arr[i] = '!';
  for (int i = 0; i < ri.size(); i++) {
    if (ri[i] == wr[i]) {
      if (arr[ri[i] - 'a'] != '!' && arr[ri[i] - 'a'] != ri[i]) die(-1);
      arr[ri[i] - 'a'] = ri[i];
    } else {
      if (arr[ri[i] - 'a'] != '!' || arr[wr[i] - 'a'] != '!') {
        if (arr[ri[i] - 'a'] != wr[i] || arr[wr[i] - 'a'] != ri[i]) die(-1);
      }
      arr[ri[i] - 'a'] = wr[i];
      arr[wr[i] - 'a'] = ri[i];
    }
  }
  set<pair<char, char> > ans;
  for (int i = 0; i <= ('z' - 'a'); i++)
    if ((i + 'a') != arr[i] && arr[i] != '!')
      ans.insert({min((char)(i + 'a'), arr[i]), max((char)(i + 'a'), arr[i])});
  cout << ans.size() << endl;
  for (auto cur : ans) {
    cout << cur.first << ' ' << cur.second << endl;
  }
}
