#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string a, b;
  char c[27] = {};
  int j, l;
  cin >> a >> b;
  l = a.size();
  for (int i = 0; i < l; i++) {
    if (c[a[i] - 'a']) {
      a[i] = c[a[i] - 'a'];
      if (a[i] != b[i]) {
        cout << "-1\n";
        return 0;
      }
    } else if (a[i] == b[i]) {
      c[a[i] - 'a'] = b[i];
    } else if (c[b[i] - 'a']) {
      cout << "-1\n";
      return 0;
    } else {
      c[a[i] - 'a'] = b[i];
      c[b[i] - 'a'] = a[i];
    }
  }
  j = 0;
  for (int i = 0; i < 26; i++) {
    if (c[i] && c[i] - 'a' != i) {
      j++;
    }
  }
  cout << j / 2 << endl;
  for (int i = 0; i < 26; i++) {
    if (c[i] && i < (c[i] - 'a')) {
      cout << char(i + 'a') << " " << c[i] << endl;
    }
  }
  return 0;
}
